Caller Information 

9916037817 / 991-603-7817 Reverse Phone Lookup

Phone Owner
Caller Type
Rahul
According to 2 people
Prank Caller
According to 10 people
Area Code
Location
N/A
Carrier
N/A
Number Variations: 991/603/7817 - 991.603.7817 - 9916037817 - 991 603 7817
Subscribe to recieve updated information regarding 991-603-7817 number

9916037817 User Reports

0 Votes
3rd Aug, 2011 by name
Reported Number: 991-603-7817
Caller type: Unknown
Phone owner: Unknown
..
0 Votes
3rd Aug, 2011 by sallu
Reported Number: 9916037817
Caller type: Unknown
Phone owner: Unknown
dfasfsdfsd
0 Votes
3rd Aug, 2011 by sallu
Reported Number: 991-603-7817
Caller type: Unknown
Phone owner: Unknown
dfasfsdfsd
0 Votes
3rd Aug, 2011 by sallu
Reported Number: 9916037817
Caller type: Unknown
Phone owner: Unknown
dfasfsdfsd
0 Votes
3rd Aug, 2011 by sallu
Reported Number: 991-603-7817
Caller type: Unknown
Phone owner: Unknown
Early life Khan is the eldest son of screenwriter Salim Khan and his first wife Salma (maiden name Sushila Charak), his paternal grandfather came to India from Afghanistan and settled in Madhya Pradesh whereas his mother is a Marathi Brahmin.[7][8] His stepmother is Helen, a former Bollywood actress, who has co-starred with him in Khamoshi: The Musical (1996) and Hum Dil De Chuke Sanam (1999). He has two brothers, Arbaaz Khan and Sohail Khan, and two sisters, Alvira and Arpita. Alvira is married to actor/director Atul Agnihotri. Khan finished his schooling through St. Stanislaus High School in Bandra, Mumbai, as did his younger brothers Arbaaz and Sohail. Earlier, he studied at The Scindia School, Gwalior for a few years along with younger brother Arbaaz.[9][10]
0 Votes
3rd Aug, 2011 by sallu
Reported Number: 9916037817
Caller type: Unknown
Phone owner: Unknown
Early life Khan is the eldest son of screenwriter Salim Khan and his first wife Salma (maiden name Sushila Charak), his paternal grandfather came to India from Afghanistan and settled in Madhya Pradesh whereas his mother is a Marathi Brahmin.[7][8] His stepmother is Helen, a former Bollywood actress, who has co-starred with him in Khamoshi: The Musical (1996) and Hum Dil De Chuke Sanam (1999). He has two brothers, Arbaaz Khan and Sohail Khan, and two sisters, Alvira and Arpita. Alvira is married to actor/director Atul Agnihotri. Khan finished his schooling through St. Stanislaus High School in Bandra, Mumbai, as did his younger brothers Arbaaz and Sohail. Earlier, he studied at The Scindia School, Gwalior for a few years along with younger brother Arbaaz.[9][10]
0 Votes
3rd Aug, 2011 by sallu
Reported Number: 991-603-7817
Caller type: Unknown
Phone owner: Unknown
Early life Khan is the eldest son of screenwriter Salim Khan and his first wife Salma (maiden name Sushila Charak), his paternal grandfather came to India from Afghanistan and settled in Madhya Pradesh whereas his mother is a Marathi Brahmin.[7][8] His stepmother is Helen, a former Bollywood actress, who has co-starred with him in Khamoshi: The Musical (1996) and Hum Dil De Chuke Sanam (1999). He has two brothers, Arbaaz Khan and Sohail Khan, and two sisters, Alvira and Arpita. Alvira is married to actor/director Atul Agnihotri. Khan finished his schooling through St. Stanislaus High School in Bandra, Mumbai, as did his younger brothers Arbaaz and Sohail. Earlier, he studied at The Scindia School, Gwalior for a few years along with younger brother Arbaaz.[9][10]
0 Votes
3rd Aug, 2011 by sallu
Reported Number: 9916037817
Caller type: Unknown
Phone owner: Unknown
Early life Khan is the eldest son of screenwriter Salim Khan and his first wife Salma (maiden name Sushila Charak), his paternal grandfather came to India from Afghanistan and settled in Madhya Pradesh whereas his mother is a Marathi Brahmin.[7][8] His stepmother is Helen, a former Bollywood actress, who has co-starred with him in Khamoshi: The Musical (1996) and Hum Dil De Chuke Sanam (1999). He has two brothers, Arbaaz Khan and Sohail Khan, and two sisters, Alvira and Arpita. Alvira is married to actor/director Atul Agnihotri. Khan finished his schooling through St. Stanislaus High School in Bandra, Mumbai, as did his younger brothers Arbaaz and Sohail. Earlier, he studied at The Scindia School, Gwalior for a few years along with younger brother Arbaaz.[9][10]
0 Votes
3rd Aug, 2011 by sallu
Reported Number: 991-603-7817
Caller type: Telemarketer
Phone owner: Unknown
Salman Khan (Hindi: सलमान ख़ान, pronounced [səlˈmaːn ˈxaːn]; born Abdul Rashid Salim Salman Khan on 27 December 1965)[1] is an Indian film actor. He has starred in more than eighty Hindi films. Khan, who made his acting debut with a minor role in the drama Biwi Ho To Aisi (1988), had his first commercial success with the blockbuster Maine Pyar Kiya (1989), for which he won a Filmfare Award for Best Male Debut. He went on to star in some of Hindi cinema's most successful films of those times, such as Saajan (1991), Hum Aapke Hain Kaun (1994), Karan Arjun (1995), Judwaa (1997), Pyar Kiya To Darna Kya (1998) and Biwi No.1 (1999), having appeared in the highest earning films of seven separate years during his career.[2] In 1999, Khan won a Filmfare Award for Best Supporting Actor for his extended appearance in Kuch Kuch Hota Hai (1998), and since then has starred in several critical and commercial successes, including Hum Dil De Chuke Sanam (1999), Tere Naam (2003), Mujhse Shaadi Karogi (2004), No Entry (2005), Partner (2007), Wanted (2009) and Dabangg (2010), which has become the second highest-grossing Bollywood film of all-time, and Ready (2011). Khan has thus established himself as one of the leading and most successful actors of Hindi cinema.[3][4][5][6]
0 Votes
3rd Aug, 2011 by shillu
Reported Number: 9916037817
Caller type: Unknown
Phone owner: Unknown
at the end of this document. In order to further enhance the quality of this publication, the author would like to hear from you, the fellow readers. Comments or suggestions on this publication are very much appreciated. Please feel free to forward me your comments through the email feedback form or the feedback forum on the author's Web site. Contents 1 Introduction to Programming 1 1.1 What is Perl? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 A Trivial Introduction to Computer Programming . . . . . . . . . . . . . . . . . . . . 1 1.3 Scripts vs. Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1.4 An Overview of the Software Development Process . . . . . . . . . . . . . . . . . . . . 4 2 Getting Started 7 2.1 What can Perl do? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.2 Comparison with Other Programming Languages . . . . . . . . . . . . . . . . . . . . 8 2.2.1 C/C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2.2.2 PHP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2.2.3 Java/JSP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.2.4 ASP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.3 What do I need to learn Perl? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.4 Make Good Use of Online Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2.5 The Traditional “Hello World” Program . . . . . . . . . . . . . . . . . . . . . . . . . . 12 2.6 How A Perl Program Is Executed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 2.7 Literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 2.7.1 Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 2.7.2 Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 2.8 Introduction to Data Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 3 Manipulation of Data Structures 23 3.1 Scalar Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 3.1.1 Assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 3.1.2 Nomenclature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 3.1.3 Variable Substitution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 3.1.4 substr() —Extraction of Substrings . . . . . . . . . . . . . . . . . . . . . . 26 3.1.5 length() —Length of String . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 3.2 Lists and Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 3.2.1 Creating an Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 3.2.2 Adding Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 3.2.3 Getting the number of Elements in an Array . . . . . . . . . . . . . . . . . . . 29 3.2.4 Accessing Elements in an Array . . . . . . . . . . . . . . . . . . . . . . . . . . 30 3.2.5 Removing Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 3.2.6 splice(): the Versatile Function . . . . . . . . . . . . . . . . . . . . . . . . . 32 3.2.7 Miscellaneous List-Related Functions . . . . . . . . . . . . . . . . . . . . . . . 33 3.2.8 Check for Existence of Elements in an Array (Avoid!) . . . . . . . . . . . . . . 35 3.3 Hashes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 3.3.1 Assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 i ii CONTENTS 3.3.2 Accessing elements in the Hash . . . . . . . . . . . . . . . . . . . . . . . . . . 40 3.3.3 Removing Elements from a Hash . . . . . . . . . . . . . . . . . . . . . . . . . 40 3.3.4 Searching for an Element in a Hash . . . . . . . . . . . . . . . . . . . . . . . . 41 3.4 Contexts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 3.5 Miscellaneous Issues with Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 4 Operators 47 4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 4.2 Description of some Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 4.2.1 Arithmetic Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 4.2.2 String Manipulation Operators . . . . . . . . . . . . . . . . . . . . . . . . . . 50 4.2.3 Comparison Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 4.2.4 Equality Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 4.2.5 Logical Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 4.2.6 Bitwise Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 4.2.7 Assignment Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 4.2.8 Other Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 4.3 Operator Precedence and Associativity . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 4.4 Constructing Your Own sort() Routine . . . . . . . . . . . . . . . . . . . . . . . . . 64 5 Conditionals, Loops & Subroutines 67 5.1 Breaking Up Your Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 5.1.1 Sourcing External Files with require() . . . . . . . . . . . . . . . . . . . . . 67 5.2 Scope and Code Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 5.2.1 Introduction to Associations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 5.2.2 Code Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69 5.3 Subroutines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 5.3.1 Creating and Using A Subroutine . . . . . . . . . . . . . . . . . . . . . . . . . 71 5.3.2 Prototypes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 5.3.3 Recursion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 5.3.4 Creating Context-sensitive Subroutines . . . . . . . . . . . . . . . . . . . . . . 78 5.4 Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 5.4.1 Declaring a Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 5.4.2 Package Variable Referencing . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 5.4.3 Package Variables and Symbol Tables . . . . . . . . . . . . . . . . . . . . . . . 81 5.4.4 Package Constructors with BEGIN fg . . . . . . . . . . . . . . . . . . . . . . . 82 5.5 Lexical Binding and Dynamic Binding . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 5.6 Conditionals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 5.7 Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 5.7.1 for loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 5.7.2 while loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 5.7.3 foreach loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 5.7.4 Loop Control Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 5.8 Leftovers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 6 References 95 6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 6.2 Creating a Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 6.3 Using References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 6.4 Pass By Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 6.5 How Everything Fits Together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 CONTENTS iii 6.6 Typeglobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 7 Object-Oriented Programming 105 7.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 7.2 Object-Oriented Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 7.2.1 Programming Paradigms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 7.2.2 Basic Ideas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 7.2.3 Fundamental Elements of Object-Oriented Programming . . . . . . . . . . . . 107 7.3 OOP Primer: Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 7.3.1 Creating and Using A Perl Class . . . . . . . . . . . . . . . . . . . . . . . . . . 110 7.3.2 How A Class Is Instantiated . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 7.4 Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 8 Files and Filehandles 119 8.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 8.2 Filehandles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 8.2.1 open a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 8.2.2 Output Redirection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121 8.3 File Input and Output Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122 8.3.1 readline() —Read A Line from Filehandle . . . . . . . . . . . . . . . . . . . 122 8.3.2 binmode() —Binary Mode Declaration . . . . . . . . . . . . . . . . . . . . . 122 8.3.3 read() —Read A Specied Number of Characters from Filehandle . . . . . . . 123 8.3.4 print()/printf() —Output To A FileHandle . . . . . . . . . . . . . . . . . 124 8.3.5 seek() —Set File Pointer Position . . . . . . . . . . . . . . . . . . . . . . . . 126 8.3.6 tell() —Return File Pointer Position . . . . . . . . . . . . . . . . . . . . . . 127 8.3.7 close() —Close An opened File . . . . . . . . . . . . . . . . . . . . . . . . . 127 8.4 Directory Traversal Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 8.4.1 opendir() —Open A Directory . . . . . . . . . . . . . . . . . . . . . . . . . 128 8.4.2 readdir() —Read Directory Content . . . . . . . . . . . . . . . . . . . . . . 128 8.4.3 closedir() —Close A Directory . . . . . . . . . . . . . . . . . . . . . . . . . 128 8.4.4 Example: File Search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128 8.5 File Test Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 8.6 File Locking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 9 Regular Expressions 137 9.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 9.2 Building a Pattern . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 9.2.1 Getting your FootWet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 9.2.2 Introduction to m// and the Binding Operator . . . . . . . . . . . . . . . . . . 139 9.2.3 Metacharacters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 9.2.4 Quantiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 9.2.5 Character Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 9.2.6 Backtracking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 9.3 Regular Expression Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 9.3.1 m//—PatternMatching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 9.3.2 s///—Search and Replace . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144 9.3.3 tr///—Global Character Transliteration . . . . . . . . . . . . . . . . . . . . 144 9.4 Constructing Complex Regular Expressions . . . . . . . . . . . . . . . . . . . . . . . . 145 iv CONTENTS 10 Runtime Evaluation & Error Trapping 149 10.1 Warnings and Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 10.2 Error-Related Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 10.3 eval . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 10.4 Backticks and system() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 10.5 Why Runtime Evaluation Should Be Restricted . . . . . . . . . . . . . . . . . . . . . . 151 10.6 Next Generation Exception Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 10.6.1 Basic Ideas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 10.6.2 Throwing Different Kinds of Errors . . . . . . . . . . . . . . . . . . . . . . . . 155 10.6.3 Other Handlers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 10.7 Other Methods To Catch Programming Errors . . . . . . . . . . . . . . . . . . . . . . 159 10.7.1 The -w Switch—EnableWarnings . . . . . . . . . . . . . . . . . . . . . . . . 159 10.7.2 Banning Unsafe ConstructsWith strict . . . . . . . . . . . . . . . . . . . . . 160 10.7.3 The -T Switch—Enable Taint Checking . . . . . . . . . . . . . . . . . . . . . 163 11 CGI Programming 169 11.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 11.2 Static Content and Dynamic Content . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 11.2.1 The Hypertext Markup Language . . . . . . . . . . . . . . . . . . . . . . . . . 169 11.2.2 TheWorldWideWeb . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170 11.3 What is CGI? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172 11.4 Your First CGI Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 11.5 GET vs. POST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 11.6 File Upload . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 11.7 Important HTTP Header Fields and Environment Variables . . . . . . . . . . . . . . . 182 11.7.1 CGI-Related Environment Variables . . . . . . . . . . . . . . . . . . . . . . . . 182 11.7.2 HTTP Header Fields . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 11.8 Server Side Includes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 11.9 Security Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 11.9.1 Why Should I Care? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 11.9.2 Some Forms of Attack Explained . . . . . . . . . . . . . . . . . . . . . . . . . 187 11.9.3 Safe CGI Scripting Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . 190 A How A HashWorks 193 A.1 Program Listing of Example Implementation . . . . . . . . . . . . . . . . . . . . . . . 193 A.2 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 A.3 Principles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 A.4 Notes on Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 B Administration 201 B.1 CPAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 B.1.1 Accessing the Module Database on theWeb . . . . . . . . . . . . . . . . . . . . 201 B.1.2 PackageManagers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 B.1.3 InstallingModules using CPAN.pm . . . . . . . . . . . . . . . . . . . . . . . . 202 B.1.4 InstallingModules—The TraditionalWay . . . . . . . . . . . . . . . . . . . . 203 C Setting Up AWeb Server 205 C.1 Apache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 C.1.1 MicrosoftWindows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205 C.1.2 Unix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210 CONTENTS v D A Unix Primer 213 D.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 D.1.1 Why Should I Care About Unix? . . . . . . . . . . . . . . . . . . . . . . . . . . 213 D.1.2 What Is Unix? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 D.1.3 The Overall Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214 D.2 Filesystems and Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 D.2.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215 D.2.2 Symbolic Links and Hard Links . . . . . . . . . . . . . . . . . . . . . . . . . . 216 D.2.3 Permission and Ownership . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 D.2.4 Processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222 D.2.5 The Special Permission Bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 E In The Next Edition 225 Index 226 vi CONTENTS Preface If you are looking for a free Perl tutorial that is packed with everything you need to know to get started on Perl programming, look no further. Presenting before you is probably the most comprehensive Perl tutorial on theWeb, the product of two years of diligence seeking reference from related books andWeb sites. Perl is a programming language that is offered at no cost. So wouldn't it be nice if you can also learn it at no cost? Packed with some background knowledge of programming in C and Visual Basic, when I started learning Perl several years ago, I couldn't even nd one good online tutorial that covered at least the basics of the Perl language and was free. Most Perl tutorials I could nd merely covered the very basic topics such as scalar/list assignment, operators and some ow control structures etc. On the other hand, although I have accumulated certain levels of experience in a number of programming languages, the ofcial Perl manual pages are quite technical with whole pages of jargons that I was not very familiar with. As a result, the book “Learning Perl” written by LarryWall, the inventor of the Perl language, naturally became the only Perl textbook available. The O'Reilly Perl Series present the most authoritative and well-written resources on the subject written by the core developers of Perl. While you are strongly recommended to grab one copy of each if you have the money, they are not so cheap, though, and that's the motive behind my writing of this tutorial—so that more people with no programming background can start learning this stupendous and powerful language in a more cost-effective way. Although this tutorial covers a rather wide range of topics, similar to what you can nd in some other Perl guidebooks, you are strongly encouraged to read those books too, since their paedagogies of teaching may suit you more. Here are several features of this tutorial: ? As this is not a printed book, I will constantly add new materials to this tutorial as needed, thus enriching the content of this tutorial. Moreover, in order to help me improve the quality of this tutorial, it is crucial for you to forward me your comments and suggestions so that I can make further improvements to it. ? Earlier drafts of this tutorial were published in HTML format on myWeb site. In response to requests made from several visitors, this tutorial has been made available in PDF format for download. I hope this will help those who are charged on time basis for connecting to the Internet. This tutorial is typeset in LATEX, a renowned document typesetting system that has been widely used in the academic community on Unix-compatible systems (although it is available on nearly any operating systems you can think of). The HTML version has been discontinued, until a solution can be found which allows both versions to be generated from the same source base. ? You will nd a list ofWeb links and references to book chapters after each chapter where applicable which contains additional materials that ambitious learners will nd helpful to further your understanding of the subject. vii viii Preface ? Throughout the text there would be many examples. In this tutorial, you will nd two types of examples — examples and illustrations. Illustrations are intended to demonstrate a particular concept just mentioned, and are shorter in general. You will nd them embedded inline throughout the tutorial. On the other hand, examples are more functional and resemble practical scripts, and are usually simplied versions of such. They usually demonstrate how different parts of a script can work together to realize the desired functionalities or consolidate some important concepts learned in a particular chapter. ? If applicable, there will be some exercises in the formof concept consolidation questions as well as programming exercises at the end of each chapter to give readers chances to test how much they understand the materials learned from this tutorial and apply their knowledge through practice. This is the First Edition of the Perl 5 Tutorial. It primarily focuses on fundamental Perl programming knowledge that any Perl programmer should be familiar with. I start with some basic ideas behind computer programming in general, and then move on to basic Perl programming with elementary topics such as operators and simple data structures. The chapter on scoping and subroutines is the gateway to subsequent, but more advanced topics such as references and object-oriented programming. The remaining chapters are rather assorted in topic, covering the use of lehandles, le I/O and regular expressions in detail. There is also a dedicated chapter on error handling which discusses facilities that you can use to locate logical errors and enhance program security. The nal chapter on CGI programming builds on knowledge covered in all earlier chapters. Readers will learn how to write a Perl program that can be used for dynamic scripting on the World Wide Web. However short, the main text already embraces the most important fundamental subjects in the Perl programming language. In the appendices, instructions are given on acquiring and installing Perl modules, setting up a basic but functional CGI-enabled Web server for script testing, and there is a voluminous coverage of Unix fundamentals. As much of Perl is based on Unix concepts, I believe a brief understanding of this operating system is benecial to Perl programmers. An appendix is also prepared to give my readers an idea of the internal structure of general hashes. While authoring of this tutorial cannot proceed indenitely, topics that were planned but cannot be included in this edition subject to time constraints are deferred to the Second Edition. A list of these topics appear at the end of this document for your reference. In the second release candidate of this tutorial I made an audacious attempt of adding into it two topics that are rarely discussed in most Perl literature. The rst is the Error CPAN module for exception handling. The second attempt, which is an even more audacious one, is an introduction of the nite-state automaton (FSA) for construction of complex regular expressions for pattern matching. While FSA is a fundamental topic in Computer Science (CS) studies, this is seldom mentioned outside the CS circle. Although there is a high degree of correspondence between regular expressions and FSA, this may not be at all obvious to a reader without relevant background, despite I have avoided rigorous treatment of the topic and tried to explain it in a manner that would be more easily communicable to fellow readers. I would like to emphasize this topic is not essential in Perl programming, and I only intend to use it as a tool to formulate better patterns. Feel free to skip it if that is not comfortable to you and I require your feedback of whether these topics can help you as I originally intended. It is important for me to reiterate that this document is not intended to be a substitute for the ofcial Perl manual pages (aka man pages) and other ofcial Perl literature. In fact, it is the set of manual pages that covers the Perl language in sufciently ne detail, and it will be the most important set of document after you have accumulated certain level of knowledge and programming experience. The Perl man pages are written in the most concise and correct technical parlance, and as a result they are not very suitable for new programmers to understand. The primary objective of this tutorial is to bridge the gap so as to supplement readers with sufcient knowledge to understand the man pages. Therefore, this tutorial presents a different perspective compared with some other Perl guidebooks available at your local bookstores from the mainstream computer book publishers. With a Computer Science background, I ix intend to go more in-depth into the principles which are central to the study of programming languages in general. Apart from describing the syntax and language features of Perl, I also tried to draw together the classical programming language design theories and explained how they are applied in Perl. With this knowledge, it is hoped that readers can better understand the jargons presented in manual pages and the principles behind. Perl is attributed by some as a very cryptic language and is difcult to learn. However, those who are knowledgeable about programming language design principles would agree Perl implements a very rich set of language features, and therefore is an ideal language for students to experiment with different programming language design principles taught in class in action. I do hope that after you have nished reading this tutorial you will be able to explore the Perl horizons on your own with condence and experience the exciting possibilities associated with the language more easily. “To help you learn how to learn” has always been the chief methodology followed in this tutorial. Time ies. Today when I am revising this preface, which was actually written before I made my initial preview release in late 2001 according to the timestamp, I am aghast to nd that it has already been nearly two years since I started writing it. Indeed, a lot of things have changed in two years. Several Perl manpages written in tutorial-style have been included into the core distribution, which are written in a more gentle way targeted at beginners. There are also more Perl resources online today than there were two years ago. However, I believe through preparing this tutorial I have also learnt a lot in the process. Despite I started this project two years ago, a major part of the text was actually written in a window of 3 months. As a result, many parts of the tutorial were unfortunately completed in a hasty manner. However, through constant renement and rewriting of certain parts of the tutorial, I believe the Second Edition will be more well-organized and coherent, while more advanced topics can be accommodated as more ample time is available. At last, thank you very much for choosing this tutorial. Welcome to the exciting world of Perl programming! Bernard Chan in Hong Kong, China 15th September, 2003 x Preface Typographical Conventions Although care has been taken towards establishing a consistent typographical convention throughout this tutorial, considering this is the rst time I try to publish in LATEX, slight deviations may be found in certain parts of this document. Here I put down the convention to which I tried to adhere: Elements in programming languages are typeset in monospace font. Important terms are typeset in bold. Profound sayings or quotes are typeset in italic. In source code listings, very long lines are broken into several lines. ¶ is placed wherever a line break occurs. Release History 30th August, 2003 First Edition, Release Candidate 1 15th September, 2003 First Edition, Release Candidate 2 01st October, 2003 First Edition, Release Candidate 3 31st December, 2003 First Edition About The Author Bernard Chan was born and raised in Hong Kong, China. He received his Bachelor's Degree in Computer Engineering from the University of Hong Kong. His major interests in the eld include information system security, networking and Web technologies. He carries a long-term career objective of becoming an avid technical writer in the area of programming. His most notable publication is the Perl 5 Tutorial. Chapter 1 Introduction to Programming 1.1 What is Perl? Extracted from the perl manpage, “Perl is an interpreted high-level programming language developed by Larry Wall.” If you have not learnt any programming languages before, as this is not a prerequisite of this tutorial, this denition may appear exotic for you. The two keywords that you may not understand are “interpreted ” and “high-level”. Because this tutorial is mainly for those who do not have any programming experience, it is better for me to give you a general picture as to how a computer program is developed. This helps you understand this denition. 1.2 A Trivial Introduction to Computer Programming You should know that, regardless of the programming language you are using, you have to write something that we usually refer to as source code, which include a set of instructions for the computer to perform some operations dictated by the programmer. There are two ways as to how the source code can be executed by the Central Processing Unit (CPU) inside your computer. The rst way is to go through two processes, compilation and linking, to transform the source code into machine code, which is a le consisting of a series of numbers only. This le is in a format that can be recognized by the CPU readily, and does not require any external programs for execution. Syntax errors are detected when the program is being compiled. We describe this executable le as a compiled program. Most software programs (e.g. most EXEs for MS-DOS/Windows) installed in your computer fall within this type. NOTES There are some subtleties, though. For example, the compiler that comes with Visual Basic 6 Learning Edition translates source code into p-code (pseudo code) which has to be further converted to machine code at runtime. Such an EXE is described as interpreted instead. Therefore, not all EXEs are compiled. On the other hand, although Java is customarily considered an interpreted language, Java source les are rst compiled into bytecode by the programmer, so syntactical errors can be checked at compile time. Another way is to leave the program uncompiled (or translate the source code to an intermediate level 1 2 Chapter 1 Introduction to Programming between machine code and source code, e.g. Java). However, the program cannot be executed on its own. Instead, an external program has to be used to execute the source code. This external program is known as an interpreter, because it acts as an intermediary to interpret the source code in a way the CPU can understand. Compilation is carried out by the interpreter before execution to check for syntax errors and convert the program into certain internal form for execution. Therefore, the main difference between compiled programs and interpreted languages is largely only the time of compilation phase. Compilation of compiled programs is performed early, while for interpreted programs it is usually performed just before the execution phase. Every approach has its respective merits. Usually, a compiled program only has to be compiled once, and thus syntax checking is only performed once. What the operating system only needs to do is to read the compiled program and the instructions encoded can be arranged for execution by the CPU directly. However, interpreted programs usually have to perform syntax check every time the program is executed, and a further compilation step is needed. Therefore, startup time of compiled programs are usually shorter and execution of the program is usually faster. For two functionally equivalent programs, a compiled program generally gives higher performance than the interpreted program. Therefore, performance-critical applications are generally compiled. However, there are a number of factors, e.g. optimization, that inuence the actual performance. Also, the end user of a compiled program does not need to have any interpreters installed in order to run the program. This convenience factor is important to some users. On the other hand, interpreters have to be installed in order to execute a program that is interpreted. One example is the Java Virtual Machine (JVM) that is an interpreter plugged into your browser to support Java applets. Java source les are translated into Java bytecode, which is then executed by the interpreter. There are some drawbacks for a compiled program. For example, every time you would like to test your software to see if it works properly, you have to compile and link the program. This makes it rather annoying for programmers to x the errors in the program (debug), although the use of makeles alleviates most of this hassle from you. Because compilation translates the source code to machine code which can be executed by the hardware circuitry in the CPU, this process creates a le in machine code that depends on the instruction set of the computer (machine-dependent). On the other hand, interpreted programs are usually platform-independent, that is, the program is not affected by the operating system on which the program is executed. Therefore, for example, if you have a Java applet on a Web site, it can most probably be executed correctly regardless of the operating system or browser a visitor is using. It is also easier to debug an interpreted program because repeated compilation is waived. TERMINOLOGY Instruction set refers to the set of instructions that the CPU executes. There are a number of types of microprocessors nowadays. For example, IBM-compatible PCs are now using the Intel-based instruction set. This is the instruction set that most computer users are using. Another prominent example is the Motorola 68000 series microprocessors in Macintosh computers. There are some other microprocessor types which exist in minority. The instruction sets of these microprocessors are different and, therefore, a Windows program cannot be executed unadapted on a Macintosh computer. In a more technical parlance, different microprocessors have different instruction set architectures. Recall that I mentioned that a compiled program consists entirely of numbers. Because a CPU is actually an electronic circuit, and a digital circuit mainly deals with Booleans (i.e. 0 and 1), so it is obvious that programs used by this circuit have to be sequences of 0s and 1s. This is what machine code actually is. However, programming entirely with numbers is an extreme deterrent to computer 1.3 Scripts vs. Programs 3 programming, because numeric programming is highly prone to mistakes and debugging is very difcult. Therefore, assembly language was invented to allow programmers to use mnemonic names to write programs. An assembler is used to translate the assembly language source into machine code. Assembly language is described as a low-level programming language, because the actions of an assembly language program are mainly hardware operations, for example, moving bits of data from one memory location to another. Programming using assembly language is actually analogous to that of machine code in disguise, so it is still not programmer friendly enough. Some mathematicians and computer scientists began to develop languages which were more machineindependent and intuitive to programmers that today we refer to as high-level programming languages. The rst several high-level languages, like FORTRAN, LISP, COBOL, were designed for specialized purposes. It was not until BASIC (Beginner's All-purpose Symbolic Instruction Code) was invented in 1966 that made computer programming unprecedentedly easy and popular. It was the rst widely-used high-level language for general purpose. Many programmers nowadays use C , another high-level language, to write software programs. The reason why we call these “high-level languages” is that they were built on top of low-level languages and hid the complexity of low-level languages from the programmers. All such complexities are handled by the interpreters or compilers automatically. This is an important design concept in Computer Science called abstraction. That's enough background information and we can now apply the concepts learned above to Perl. Perl (Practical Extraction and Reporting Language) was designed by Larry Wall, who continues to develop newer versions of the Perl language for the Perl community today. Perl does not create standalone programs and Perl programs have to be executed by a Perl interpreter. Perl interpreters are now available for virtually any operating system, including but not limited to Microsoft Windows (Win32) and many avours of Unix. As I quoted above, “Perl is a language optimized for scanning arbitrary text les, extracting information from those text les, and printing reports based on that information.” This precise description best summarizes the strength of Perl, mainly because Perl has a powerful set of regular expressions with which programmers can specify search criteria (patterns) precisely. You are going to see a whole chapter devoted to regular expression in Chapter 9. Perl is installed on many Web servers nowadays for dynamic Web CGI scripting. Perl programs written as CGI applications are executed on servers where the Perl source les are placed. Therefore, there is no need to transfer the Perl source to and from the server (as opposed to client-side scripts like JavaScript or Java applets). Guestbooks, discussion forums and many powerful applications for the Web can be developed using Perl. There is one point which makes Perl very exible — there is always more than one approach to accomplish a certain task, and programmers can pick whatever approach that best suits the purpose. 1.3 Scripts vs. Programs There has always been some arguments over whether to use the term “script” or “program” for Perl source les. In general, a piece of code that is executed by hardware or a software interpreter, written in some kind of programming languages, is formally called a “program”. This is a general term that applies to programs written in machine instructions, or any programs that are compiled or interpreted. However, it is also common today to hear that people use the term “script” to refer to programs that are interpreted, especially those executed on the command line. In my opinion, it is not important to draw a distinction between the two terms as both are considered equally acceptable and understandable nowadays. In many situations people just use both interchangeably. 4 Chapter 1 Introduction to Programming I am more inclined towards calling Perl programs and CGI programs running on a Perl backend as scripts, so I will adhere to this terminology in this tutorial. 1.4 An Overview of the Software Development Process An intuitive software development process is outlined below. Note that this process is not tailored for Perl programming in particular. It is a general development process that can be applied to any programming projects with any programming languages. For additional notes specic to Perl, please refer to the next chapter. Because this tutorial does not assume readers to have any programming experience, it is appropriate for me to give you an idea as to the procedure you will most probably follow when you write your programs. In general, the process of development of a software project could be broken down into a number of stages. Here is an outline of the stages involved: ? Requirements Analysis First you need to identify the requirements of the project. Simply speaking, you will need to decide what your program should do (known as functional requirements), and note down other requirements that are important but not related to the functions of your program (known as non-functional requirements), for example, a requirement that the user interface should be user friendly. You have to make a list of the requirements, and from it you will need to decide whether you have the capability to complete them. You may also want to prioritize them such that the most important functionalities are developed rst, and other parts can be added subsequently. ? Systems Design From the requirements determined you can then dene the scope of the project. Instead of putting the whole program in one piece, we will now organize the program into several components (or subsystems—a part of the entire system). As we will discuss later in this tutorial, modularization facilitates code reuse and make correction of bugs (debug) easier. Two major models exist today — decomposition based on functions and decomposition based on objects. After you have xed the model, you decide on which functions or object methods are to be associated with which source le or object, and determine how these components interact with each other to perform the functionalities. Note that you don't need to decide on how these source les or objects are implemented in real source code at this stage—it is just an overall view of the interaction between the components. We emphasize functional decomposition in the rst part of the tutorial, while object-oriented programming will be covered in a later part of this tutorial. ? Program Design After we have determined how the components interact with each other, we can now decide how each function or object method is implemented. For each function, based on the actions to perform you have to develop an algorithm, which is a well-dened programming-languageindependent procedure to carry out the actions specied. You may want to use a owchart or some pseudocode to illustrate the ow of the program. Pseudocode is expressed in a way resembling real programming source code, except language-dependent constructs are omitted. As pseudocode is language independent, you can transforman idea from pseudocode to source code in any programming languages very easily. There isn't a single standardized pseudocode syntax. In many cases, pseudocode can even be written in English-like statements because pseudocode is written to demonstrate how a program is supposed to work, and provided it communicates the idea clearly it sufces. It is up to you as the author to express pseudocode in whatever way the algorithm is best illustrated. 1.4 An Overview of the Software Development Process 5 ? Coding This is largely the continuation of the Program Design stage to transform your algorithm into programming language constructs. If you have worked out the algorithm properly this should be a piece of cake. ? Unit Testing Unit testing corresponds to Program Design. As each function or object method has a predened behaviour, they can be tested individually to see if such behaviour agree to that dened. Most of the time when we are talking about debugging, we are describing this stage. ? Systems Testing Systems Testing corresponds to System Design. This is to test if the components interact with each other in exactly the same way as designed in the Systems Design stage. ? Requirements Validation This corresponds to requirements analysis. The software developed is compared against the requirements to ensure each functionality has been incorporated into the system and works as expected. ? Maintenance By now the software has been developed but you cannot simply abandon it. Most probably we still need to develop later versions, or apply patches to the current one as new bugs are found in the program. Software for commercial distribution especially needs investment of a lot of time and effort at this stage capturing user feedback, but software not distributed commercially should also pay attention to this stage as this affects how well your software can be further developed. Of course, for the examples in this tutorial that are so short and simple we don't need such an elaborate development procedure. However, you will nd when you develop a larger-scale project that having a well-dened procedure is essential to keep your development process in order. This is just one of the many process models in existence today. Discussion of such process models can be found in many fundamental text for Software Engineering, and are beyond the scope of this tutorial. Actually, what I have presented was a variant of theWaterfall process model, and is considered one that, if employed, is likely to delay project schedules and result in increased costs of software development. The reason I present it here is that the Waterfall model is the easiest model to understand. Because presentation of process models is out of the scope of the tutorial, some Web links will be presented at the end of this chapter from which you will nd selected texts describing process models, including the Rational Unied Process which I recommend as an improved process model for larger-scale development projects. Adoption of an appropriate process model helps guide the development process with optimized usage of resources, increased productivity and software that are more fault-tolerant. Summary ” Source code include a set of instructions to be executed by the computer through levels of translation. ” Low-level programming languages involves architecture-dependent programming with machine code or assembly language. ” High-level programming languages are built on top of low-level languages and source programs can usually be platform-independent. ” Source programs are either explicitly precompiled into object code, or are implicitly compiled before execution by the interpreter. 6 Chapter 1 Introduction to Programming ” Perl is an interpreted high-level programming language developed by Larry Wall. ” Following a well-dened software development process model helps keep the development process systematic and within budgets. Web Links 1.1 Evolution of Programming Languages http://lycoskids.infoplease.com/ce6/sci/A0860536.html 1.2 Rational Unied ProcessWhitepapers http://www.rational.com/products/rup/whitepapers.jsp Chapter 2 Getting Started 2.1 What can Perl do? I understand it is a full wastage of time for you to have read through half of a book to nd that it is not the one you are looking for. Therefore, I am going to let you know what you will learn by following this tutorial as early as possible. If you are looking for a programming language to write an HTML editor that runs on the Windows platform, or if you would like to write a Web browser or ofce suite, then Perl does not seem to be an appropriate language for you. C/C , Java or (if you are using Windows) Visual Basic are likely to be more appropriate choices for you. Although it appears that Perl is not the optimum language for developing applications with a graphical user interface (but you can, with Perl/Tk or native modules like WIN::GUI), it is especially strong in doing text manipulation and extraction of useful information. Therefore, with database interfacing it is possible to build robust applications that require a lot of text processing as well as database management. Perl is the most popular scripting language used to write scripts that utilize the Common Gateway Interface (CGI), and this is how most of us got to know this language in the rst place. A cursory look at the CGI Resource IndexWeb site provided me with a listing of about 3000 Perl CGI scripts, compared with only 220 written in C/C , as of this writing. There are quite many free Web hosts that allow you to deploy custom Perl CGI scripts, but in general C/C CGI scripts are virtually only allowed unless you pay. In particular, there are several famous programs written in Perl worth mentioning here: ? YaBB is an open source bulletin board system. While providing users with many advanced features that could only be found on commercial products, it remains as a free product. Many webmasters use YaBB to set up their BBS. Another popular BBS written in Perl is ikonboard, featuring a MySQL/PostgreSQL database back-end. ? Thanks to the powerful pattern matching functions in Perl, search engines can also be written in Perl with unparalleled ease. Perlfect Search is a very goodWeb site indexing and searching system written in Perl. You will learn more about Perl CGI programming in Chapter 11 of this tutorial. 7 8 Chapter 2 Getting Started 2.2 Comparison with Other Programming Languages There are many programming languages in use today, each of which placing its emphasis on certain application domains and features. In the following section I will try to compare Perl with several popular programming languages for the readers to decide whether Perl is appropriate for you. 2.2.1 C/C Perl is written in the C programming language. C is extensively used to develop many system software. C is an extension of C, adding various new features such as namespaces, templates, object-oriented programming and exception handling etc. Because C and C programs are compiled to native code, startup times of C/C programs are usually very short and they can be executed very efciently. Perl allows you to delegate part of your program in C through the Perl-C XS interface. This Perl-C binding is extensively used by cryptographic modules to implement the core cryptographic algorithms, because such modules are computation-intensive. While C/C is good for performance-critical applications, C/C suffers a number of drawbacks. First, C/C programs are platform dependent. A C/C program written on Unix is different from one on Windows because the libraries available on different platforms are different. Second, because C/C is a very structured language, its syntax is not as exible as scripting languages such as Perl, Tcl/Tk or (on Unix platforms) bash. If you are to write two functionally equivalent programs in C/C and Perl, very likely the C/C version requires more lines of code compared with Perl. And also, improperly written C/C programs are vulnerable to memory leak problems where heap memory allocated are not returned when the program exits. On aWeb server running 247 with a lot of visitors, a CGI script with memory leak is sufcient to paralyze the machine. 2.2.2 PHP Perl has been the traditional language of choice for writing server-side CGI scripts. However, in recent years there has been an extensive migration from Perl to PHP.Many programmers, especially those who are new to programming, have chosen PHP instead of Perl. What are the advantages of PHP over Perl? PHP is from its infancy Web-scripting oriented. Similar to ASP or JSP, it allows embedding of inline PHP code inside HTML documents that makes it very convenient to embed small snippets of PHP code, e.g. to update a counter when a visitor views a page. Perl needs Server Side Includes (SSI) or an additional package “eperl” to implement a similar functionality. Also, it inherits its language syntax from a number of languages so that it has the best features of many different languages. It mainly inherits from C/C , and portions from Perl and Java. It uses I/O functions similar to that in C, that are also inherited into Perl, so it is relatively easy for Perl programmers to migrate to PHP. While PHP supports the object-oriented paradigm, most of its functionalities are provided through functions. When PHP is compiled the administrator decides the sets of functionalities to enable. This in turn determines the sets of functions enabled in the PHP installation. I'm personally sceptical of this approach, because in practice only a small subset of these functions is frequently used. On the other hand, Perl only has a small set of intrinsic functions covering the most frequently used functionalities. Other functionalities are delegated to modules which are only installed and invoked as needed. As I will introduce shortly and in Appendix B, the Comprehensive Perl Archive Network (CPAN) contains a comprehensive and well-organized listing of ready-made Perl modules that you can install and use very easily. 2.3 What do I need to learn Perl? 9 2.2.3 Java/JSP Sun Microsystems developed the Java language and intended to target it as a general purpose programming language. It is from the ground up object-oriented and platform independent. Functionalities are accessed through the Java API, consisting of hierarchies of classes similar to that of Perl. Java Server Pages (JSP) is aWeb scripting environment similar to ASP except with a Java syntax. Similar to C/C , the Java syntax is very structured and thus are not as exible as scripting languages like Perl. Also, Java itself is not just an interpreter, it is a virtual machine over which programmers are totally abstracted from the underlying operating system platforms, which allows the Java API to be implemented on top of this platform-independent layer. For those who have programmed in Java before, you will probably nd that the Java Virtual Machine takes rather long time to load, especially on lower-end systems with limited computational power. This defers the possibility of widespread deployment of Java programs. While Perl is not strictly a general-purpose programming language like Java, I found it difcult to compare Perl and Java because of their different natures. However, if conned to the purpose of Web server scripting, I generally prefer Perl to JSP for its exibility and lightweight performance. Despite this, I feel that Java is a language that is feature-rich and if time allows, you are strongly encouraged to nd out more about this stupendous language, which is expecting increasing attention in mobile and embedded devices because of its platform independence. 2.2.4 ASP Active Server Pages (ASP) is only available on Windows NT-series operating systems where Internet Information Services (IIS) is installed (although alternative implementations of ASP on other system architectures exist, e.g. Sun Chili!Soft ASP, which is a commercial product that runs on Unix, but generally considered not very stable). Running on a WindowsWeb server, ASP can impose a tighter integration with Microsoft technologies, so that the use of, say, ActiveX data objects (ADO) for database access can be made a lot easier. However, IIS is especially vulnerable to remote attacks when operated as a Web server. Numerous service packs have been released to patch the security holes in IIS and Windows NT. However, new holes are still being discovered from time to time that makes the deployment ofWindows NT/IIS as theWeb server of choice not very favourable. On the other hand, Apache, the renownedWeb server for Unix and now for other operating systems as well, has far less security concerns and are less susceptible to remote attacks. Apache also has the largest installation base among all Web server software, taking up more than 60% of the market share. 2.3 What do I need to learn Perl? You don't need to pay a penny to learn and use Perl. Basically, a text editor that handles text-only les and a working installation of the Perl interpreter are all that you will need. Under Microsoft Windows, Notepad meets the minimum requirement. However, a whole page of code in black is not visually attractive in terms of readability. Some text editors have the feature of syntax highlighting, with different parts of a statement displayed in different colours. Good colouring makes the source les more pleasurable to look at (such colouring is used for display only and will not be saved to le). However, avoid using word processors like Microsoft Word or Wordpad which add proprietary control codes on le save by default. The Perl interpreter does not recognize these special formats. If you have to use these word processors, ensure that your les are saved as plain text ASCII format so 10 Chapter 2 Getting Started Figure 2.1: Editing a Perl source le with GVIM, running on GNU/Linux that the Perl interpreter can access them. AnyEdit and UltraEdit are nice text editors on the Windows platform. On Unix variants, emacs and vim are stupendous text editors featuring syntax highlighting proles for most programming languages with a lot of powerful features. Fig. 2.1 shows a screenshot of a Perl source le edited with GVIM, a port of vim that runs on Windows, X-Windows with the GTK library on Unix/Linux and many other platforms. This is my favourite text editor and is used to construct my entire Web site. If you are using one of the mainstream operating systems, the perl interpreter can be downloaded from the download section of perl.com. perl.com is the ofcial Web site for the Perl language and you can nd the download links to all available interpreter versions there. Choose the version which matches your operating system. When you go to the download page you will see two versions, namely the stable production release and the experimental developer's release. The stable release is the version I recommend to new users, because the developer's version is for more advanced users to beta test the new version. It may still contain bugs and may give incorrect results. The les you have to download are under the heading “binary distribution”. Do not download the source code distribution unless you know exactly how to compile and install them. In case you are using an operating system that is not listed, a good place to nd a binary distribution for your operating system is the CPAN, located at here, which contains a fairly comprehensive list of platforms on which Perl can run. For Windows users, most probably you should download the Activestate distribution of Perl. It is very easy to install, with some extra tools bundled in the package for easy installation of new modules. For GNU/Linux users, most probably Perl is already installed or available as RPM (Redhat Package Manager) or DEB (Debian packages) formats. As many Linux distributions already have builtin support for RPM packages, you may look at your installation discs and you are likely to nd some RPM binaries for Perl if it is not yet installed. For other Unix systems, you may nd tarballs containing the Perl binaries. If no binaries are available for your system, you can still build from sources by downloading the source distribution from the CPAN. To check if perl is installed on your system, simply open a 2.4 Make Good Use of Online Resources 11 terminal and type perl -v. If Perl is installed you will have the version information of Perl installed displayed on screen. If error messages appear, you will need to install it. Installation of Perl will not be covered in this tutorial, and you should look for the installation help documents for details. NOTES Because Perl is an open source software, which releases the source code to the public for free, you will see the source code distribution listed. Yet for usual programming purposes there is no need to download the source les unless binary distributions are not available for your system. An exception is if you are using one of the operating systems in the Unix family (including Linux). There are already compilation tools in these operating systems and you can manually compile Perl from sources and install it afterwards. However, note that compilation can be a very time-consuming process, depending on the performance of your system. If you are using Linux, binary distributions in the form of RPM or DEB packages can be installed very easily. Only if you cannot nd a binary distribution for your platform that you are encouraged to install from source package. 2.4 Make Good Use of Online Resources You may need to seek reference while you are learning the language. As a new user you are not recommended to start learning Perl by reading the man-pages or the reference manuals. They are written in strict technical parlance that beginners, especially those who do not have prior programming experience or basic knowledge in Computer Science, would nd reading them real headaches. You are recommended to follow this tutorial (or other tutorials or books) to acquire some basic knowledge rst, and these reference documents will become very useful for ambitious learners to know more about the language, or when you have doubt on a particular subject you may be able to nd the answers inside. In this course I will try to cover some important terms used in the reference materials to facilitate your understanding of the text. For the time being, you may want to have several books on Perl for cross-referencing purposes. I have tried to write this tutorial in a way that beginners should nd it easy to follow, yet you may need to consult these books if you have any points that you don't understand fully. Although you are not advised to read the ofcial reference documents too early, in some later parts I may refer you to read a certain manpage. A manpage, on Unix/Linux systems, is a help document on a particular aspect. To read a particular manpage, (bring up a terminal if you are in X-Windows) type man followed by the name of the manpage, for example, man perlvar, the perlvar manpage will be displayed. For other platforms, manpages may usually come in the format of HTML les. Consult the documentation of your distribution for details. There is an online version of the Perl ofcial documentation at perldoc.com. It contains the Perl man pages as well as documentation of the modules shipped with Perl. In fact, there are now several manpages that are targeted at novice programmers. For instance, the perlintro manpage is a brief introduction to the fundamental aspects of the Perl language that you should master fully in order to claim yourself a Perl programmer. You are also reminded of the vast varieties of Perl resources online. There are many Perl newsgroups on the USENET and mailing lists devoted to Perl. Your questions may be readily answered by expert Perl 12 Chapter 2 Getting Started programmers there. Of course, try to look for a solution from all the resources you can nd including the FAQs before you post! Otherwise, your question may simply be ignored. Perl Monks is also a very useful resource to Perl users. dmoz.org contains a nice selection of Perl-related sites. You can nd a similar list of entries on Yahoo!. Google is the best search engine for programmers. You can usually get very accurate search results that deliver what you need. For example, by specifying the terms “Perl CGI.pm example”, you will get screenfuls of links to examples demonstrating the various uses of the CGI.pm module. As you will see later, this module is the central powerhouse allowing you to handle most operations involving CGI programming with unparalleled ease. For materials not covered in this tutorial or other books, a search phrase can be constructed in a similar manner that allows you to nd documentation and solutions to your questions at your ngertips. Of course, don't forget to experiment yourself! CPAN, the Comprehensive Perl Archive Network is a nice place where you can download a lot of useful modules contributed by other Perl programmers. By using these modules you can enforce code reuse, rather than always inventing code from scratch again. There are so many modules on the CPAN available that you would be surprised at how active the Perl community has been. Some CPAN modules are well-documented, some are not. You may need to try to t the bits and pieces together and see if it works. This requires much time and effort, but you can learn quite a lot from this process. 2.5 The Traditional “HelloWorld” Program Traditionally, the rst example most book authors use to introduce a programming language is what is customarily called a “Hello World” program. The action of this program is extremely simple—simply displays the text “Hello World” to the screen and does nothing else. For all examples in this tutorial of which source code are given in the text, you are encouraged to type them in yourself instead of executing the examples downloaded frommyWeb site, since it is more likely that by doing so you would understand the materials more quickly. Let's write a “Hello World” program to see the procedures we take to develop a Perl program. If you are on Windows, it is a good practice to check if the path to the Perl interpreter has been added to the path list in C:nAutoexec.bat. In this way, you can change to the path containing your Perl source les and can run the interpreter without specifying its path. The setup program of your distribution would probably have done

Report a Caller from 991-603-7817 Number

Your Name or Nickname
Your E-mail
 
Caller's Phone Number
Caller ID (optional)
Caller Name (optional)
Caller Type
Call Details
Confirmation code

Report 991-603-7817 Number

If you recived a phone call or have any information availible regarding phone number 9916037817 / 991-603-7817 report immidiately by filling in the form below
Free reverse phone number lookupFree reverse phone number lookup

Browse By Area Code

0xx3xx7xx
1xx4xx8xx
2xx5xx9xx
Searching Your Computer
Cell Phone GPS Tracking
4 Tips For a Successful Phone Call