Impatient Perl

Cover Art (front and rear) on the pocket version of Perl is impatient excluded from this license. Album art is copyright 2004 Greg London, ….

More PDF Content

Impatient Perl
1 The Impatient Introduction to Perl…7
1.1 The history of perl in 100 words or less…7
1.2 Basic Formatting for this Document…7
1.3 Do You Have Perl Installed…8
1.4 Your First Perl Script, EVER…9
1.5 Default Script Header…9
1.6 Free Reference Material…10
1.7 Cheap Reference Material…10
1.8 Acronyms and Terms…10
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…13
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…15
2.1.1.11 Multi-Line Strings, HERE Documents…15
2.1.2 Scalar Numbers…16
2.1.2.1 Numeric Literals…16
2.1.2.2 Numeric Functions…16
2.1.2.3 abs…16
2.1.2.4 int…16
2.1.2.5 trigonometry (sin,cos)…17
2.1.2.6 exponentiation…17
2.1.2.7 sqrt…17
2.1.2.8 natural logarithms(exp,log)…18
2.1.2.9 random numbers (rand, srand)…18
2.1.3 Converting Between Strings and Numbers…19
2.1.3.1 Stringify…19
2.1.3.1.1 sprintf…19
2.1.3.2 Numify…20
2.1.3.2.1 oct…21
2.1.3.2.2 hex…21
2.1.3.2.3 Base Conversion Overview…21
2.1.4 Undefined and Uninitialized Scalars…22
2.1.5 Booleans…23
2.1.5.1 FALSE…24
2.1.5.2 TRUE…24
2.1.5.3 Comparators…25
2.1.5.4 Logical Operators…26
2.1.5.4.1 Default Values…27
2.1.5.4.2 Flow Control…27
2.1.5.4.3 Precedence…27
2.1.5.4.4 Assignment Precedence…27
2.1.5.4.5 Flow Control Precedence…28
2.1.5.4.6 Conditional Operator…28
2.1.6 References…29
2.1.7 Filehandles…31
2.1.8 Scalar Review…32
2.2 Arrays…32
2.2.1 scalar (@array)…33
2.2.2 push(@array, LIST)…34
2.2.3 pop(@array)…34
2.2.4 shift(@array)…35
2.2.5 unshift( @array, LIST)…35
2.2.6 foreach (@array)…36
2.2.7 sort(@array)…37
2.2.8 reverse(@array)…38
2.2.9 splice(@array)…39
2.2.10 Undefined and Uninitialized Arrays…39
2.3 Hashes…39
2.3.1 exists ( $hash{$key} )…41
2.3.2 delete ( $hash{key} )…42
2.3.3 keys( %hash )…42
2.3.4 values( %hash )…43
2.3.5 each( %hash )…43
2.4 List Context…47
2.5 References…49
2.5.1 Named Referents…50
2.5.2 References to Named Referents…50
2.5.3 Dereferencing…50
2.5.4 Anonymous Referents…51
2.5.5 Complex Data Structures…53
2.5.5.1 Autovivification…54
2.5.5.2 Multidimensional Arrays…55
2.5.5.3 Deep Cloning, Deep Copy…56
2.5.5.4 Data Persistence…56
2.5.6 Stringification of References…56
2.5.7 The ref() function…57
3 Control Flow…58
3.1 Labels…60
3.2 last LABEL;…60
3.3 next LABEL;…60
3.4 redo LABEL;…60
4 Packages and Namespaces and Lexical Scoping…61
4.1 Package Declaration…61
4.2 Declaring Package Variables With our…62
4.3 Package Variables inside a Lexical Scope…62
4.4 Lexical Scope…63
4.5 Lexical Variables…63
4.6 Garbage Collection…65
4.6.1 Reference Count Garbage Collection…65
4.6.2 Garbage Collection and Subroutines…66
4.7 Package Variables Revisited…67
4.8 Calling local() on Package Variables…68
5 Subroutines…69
5.1 Subroutine Sigil…69
5.2 Named Subroutines…69
5.3 Anonymous Subroutines…70
5.4 Data::Dumper and subroutines…70
5.5 Passing Arguments to/from a Subroutine…70
5.6 Accessing Arguments inside Subroutines via @_…71
5.7 Dereferencing Code References…71
5.8 Implied Arguments…72
5.9 Subroutine Return Value…73
5.10 Returning False…73
5.11 Using the caller() Function in Subroutines…74
5.12 The caller() function and $wantarray…75
5.13 Context Sensitive Subroutines with wantarray()…75
6 Compiling and Interpreting…76
7 Code Reuse, Perl Modules…78
8 The use Statement…78
9 The use Statement, Formally…79
9.1 The @INC Array…79
9.2 The use lib Statement…80
9.3 The PERL5LIB and PERLLIB Environment Variables…80
9.4 The require Statement…80
9.5 MODULENAME -> import (LISTOFARGS)…81
9.6 The use Execution Timeline…82
10 bless()…83
11 Method Calls…85
11.1 Inheritance…86
11.2 use base…87
11.3 INVOCANT->isa(BASEPACKAGE)…88
11.4 INVOCANT->can(METHODNAME)…88
11.5 Interesting Invocants…88
12 Procedural Perl…90
13 Object Oriented Perl…90
13.1 Class…94
13.2 Polymorphism…94
13.3 SUPER…95
13.4 Object Destruction…97
14 Object Oriented Review…98
14.1 Modules…98
14.2 use Module…98
14.3 bless / constructors…98
14.4 Methods…99
14.5 Inheritance…99
14.6 Overriding Methods and SUPER…99
15 CPAN…100
15.1 CPAN, The Web Site…100
15.2 CPAN, The Perl Module…100
15.3 Plain Old Documentation (POD) and perldoc…103
15.4 Creating Modules for CPAN with h2xs…103
16 The Next Level…104
17 Command Line Arguments…104
17.1 @ARGV…105
17.2 Getopt::Declare…107
17.2.1 Getopt::Declare Sophisticated Example…108
18 File Input and Output…110
18.1 open…110
18.2 close…110
18.3 read…110
18.4 write…111
18.5 File Tests…112
18.6 File Globbing…112
18.7 File Tree Searching…113
19 Operating System Commands…114
19.1 The system() function…114
19.2 The Backtick Operator…114
19.3 Operating System Commands in a GUI…114
20 Regular Expressions…115
20.1 Variable Interpolation…116
20.2 Wildcard Example…117
20.3 Defining a Pattern…117
20.4 Metacharacters…118
20.5 Capturing and Clustering Parenthesis…120
20.5.1 $1, $2, $3, etc Capturing parentheses…120
20.5.2 Capturing parentheses not capturing…121
20.6 Character Classes…121
20.6.1 Metacharacters Within Character Classes…122
20.7 Shortcut Character Classes…122
20.8 Greedy (Maximal) Quantifiers…123
20.9 Thrifty (Minimal) Quantifiers…123
20.10 Position Assertions / Position Anchors…124
20.10.1 The \\b Anchor…124
20.10.2 The \\G Anchor…125
20.11 Modifiers…127
20.11.1 Global Modifiers…127
20.11.2 The m And s Modifiers…127
20.11.3 The x Modifier…129
20.12 Modifiers For m{} Operator…130
20.13 Modifiers for s{}{} Operator…130
20.14 Modifiers for tr{}{} Operator…130
20.15 The qr{} function…130
20.16 Common Patterns…130
20.17 Regexp::Common…131
21 Parsing with Parse::RecDescent…132
22 Perl, GUI, and Tk…135
23 GNU Free Documentation License…136

Download Impatient Perl pdf from blob.perl.org, 151 pages, 469.58KB.