Learning Perl the Hard Way.pdf

(327 KB) Pobierz
Learning Perl the Hard Way
ii
1074596657.001.png
Learning Perl the Hard Way
Allen B. Downey
Version 0.9
April 16, 2003
Copyright c 2003 Allen Downey.
Permission is granted to copy, distribute, and/or modify this document under
the terms of the GNU Free Documentation License, Version 1.1 or any later
version published by the Free Software Foundation; with no Invariant Sections,
with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license
is included in the appendix entitled “GNU Free Documentation License.”
The GNU Free Documentation License is available from www.gnu.org or by
writing to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307, USA.
The original form of this book is L A T E X source code. Compiling this L A T E X
source has the eect of generating a device-independent representation of the
book, which can be converted to other formats and printed.
The L A T E X source for this book is available from
thinkapjava.com
This book was typeset using L A T E X. The illustrations were drawn in xg. All
of these are free, open-source programs.
Contents
1
Arrays and Scalars
1
1.1
Echo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1
1.2
Errors
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3
1.3
Subroutines
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4
1.4
Local variables
. . . . . . . . . . . . . . . . . . . . . . . . . . .
4
1.5
Array elements
. . . . . . . . . . . . . . . . . . . . . . . . . . .
4
1.6
Arrays and scalars
. . . . . . . . . . . . . . . . . . . . . . . . .
5
1.7
List literals
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6
1.8
List assignment . . . . . . . . . . . . . . . . . . . . . . . . . . .
6
1.9
The shift operator . . . . . . . . . . . . . . . . . . . . . . . . .
7
1.10
File handles . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7
1.11 cat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
8
1.12 foreach and @ . . . . . . . . . . . . . . . . . . . . . . . . . . .
9
1.13
Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
10
2
Regular expressions
11
2.1
Pattern matching . . . . . . . . . . . . . . . . . . . . . . . . . .
11
2.2
Anchors
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
12
2.3
Quantiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
12
2.4
Alternation
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
13
2.5
Capture sequences
. . . . . . . . . . . . . . . . . . . . . . . . .
14
2.6
Minimal matching
. . . . . . . . . . . . . . . . . . . . . . . . .
14
2.7
Extended patterns
. . . . . . . . . . . . . . . . . . . . . . . . .
15
1074596657.002.png
Zgłoś jeśli naruszono regulamin