Permission is granted to copy, distribute and/or modify this document under the terms of
the GNU Free Documentation License, Version 1.2 or any later version published by the
Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no
Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free
Documentation License".
1 The Impatient Introduction to Perl.......................6
1.1 The history of perl in 100 words or less.............6
1.2 Basic Formatting for this Document...................6
1.3 Do You Have Perl Installed...........................7
1.4 Your First Perl Script, EVER.........................7
1.5 Default Script Header................................8
1.6 Free Reference Material..............................9
1.7 Cheap Reference Material.............. ............. .9
1.8 Acronyms and Terms...................................9
2 Storage.................................................11
2.1 Scalars.............................................11
2.1.1 Scalar Strings..................................12
2.1.1.1 String Literals.............................12
2.1.1.2 Single quotes versus Double quotes..........12
2.1.1.3 chomp.......................................13
2.1.1.4 concatenation...............................13
2.1.1.5 repetition..................................13
2.1.1.6 length......................................13
2.1.1.7 substr......................................13
2.1.1.8 split.......................................14
2.1.1.9 join........................................14
2.1.1.10 qw.........................................14
2.1.2 Scalar Numbers..................................15
2.1.2.1 Numeric Literals............................15
2.1.2.2 Numeric Functions...........................15
2.1.2.3 abs.........................................15
2.1.2.4 int.........................................15
2.1.2.5 trigonometry (sin,cos,tan)..................16
2.1.2.6 exponentiation..............................16
2.1.2.7 sqrt........................................16
2.1.2.8 natural logarithms(exp,log).................17
2.1.2.9 random numbers (rand, srand)................17
2.1.3 Converting Between Strings and Numbers..........18
2.1.3.1 Stringify...................................18
2.1.3.1.1 sprintf.................................19
2.1.3.2 Numify......................................19
2.1.3.2.1 oct.....................................19
2.1.3.2.2 hex.....................................20
2.1.4 Undefined and Uninitialized Scalars.............20
2.1.5 Booleans........................................21
2.1.5.1 FALSE.......................................22
2.1.5.2 TRUE........................................22
2.1.5.3 Comparators.................................23
2.1.5.4 Logical Operators...........................23
2.1.5.4.1 Default Values..........................24
2.1.5.4.2 Flow Control............................25
2.1.5.4.3 Precedence..............................25
2.1.5.4.4 Assignment Precedence...................25
2.1.5.4.5 Flow Control Precedence.................25
2.1.6 References......................................26
2.1.7 Filehandles.....................................27
2.1.8 Scalar Review...................................27
2.2 Arrays..............................................27
2.2.1 scalar (@array)........ ........ ........ ....... .29
2.2.2 push(@array, LIST)..............................29
2.2.3 pop(@array).....................................30
2.2.4 shift(@array)...................................30
2.2.5 unshift( @array, LIST)..........................30
2.2.6 foreach (@array)................................31
2.2.7 sort(@array)....................................32
2.2.8 reverse(@array).................................33
2.2.9 splice(@array)..................................33
2.2.10 Undefined and Uninitialized Arrays.............33
2.3 Hashes..............................................34
2.3.1 exists ( $hash{$key} )..........................35
2.3.2 delete ( $hash{key} )...........................36
2.3.3 keys( %hash )...................................37
2.3.4 values( %hash ).................................38
2.3.5 each( %hash )...................................38
2.4 List Context........................................43
2.5 References..........................................45
2.5.1 Named Referents.................................46
2.5.2 References to Named Referents...................46
2.5.3 Dereferencing...................................46
2.5.4 Anonymous Referents.............................47
2.5.5 Complex Data Structures.........................49
2.5.5.1 Autovivification............................50
2.5.5.2 Multidimensional Arrays.....................51
2.5.6 Stringification of References...................51
2.5.7 The ref() function..............................52
3 Control Flow............................................53
3.1 Labels..............................................54
3.2 last LABEL;.........................................55
3.3 next LABEL;.........................................55
3.4 redo LABEL;.........................................55
4 Packages and Namespaces and Lexical Scoping............55
4.1 Package Declaration.................................55
4.2 Declaring Package Variables With our................56
4.3 Package Variables inside a Lexical Scope............57
4.4 Lexical Scope.......................................58
4.5 Lexical Variables...................................58
4.6 Garbage Collection..................................60
4.6.1 Reference Count Garbage Collection..............60
4.6.2 Garbage Collection and Subroutines..............60
4.7 Package Variables Revisited.........................61
4.8 Calling local() on Package Variables................62
5 Subroutines.............................................64
5.1 Subroutine Sigil....................................64
5.2 Named Subroutines...................................64
5.3 Anonymous Subroutines...............................65
5.4 Data::Dumper and subroutines........................65