1PERL(1) Perl Programmers Reference Guide PERL(1)
2
3
4
6 perl - Practical Extraction and Report Language
7
9 perl [ -sTtuUWX ] [ -hv ] [ -V[:configvar] ]
10 [ -cw ] [ -d[t][:debugger] ] [ -D[number/list] ]
11 [ -pna ] [ -Fpattern ] [ -l[octal] ] [ -0[octal/hexadecimal] ]
12 [ -Idir ] [ -m[-]module ] [ -M[-]'module...' ] [ -f ]
13 [ -C [number/list] ] [ -P ] [ -S ] [ -x[dir] ]
14 [ -i[extension] ]
15 [ [-e|-E] 'command' ] [ -- ] [ programfile ] [ argument ]...
16
17 If you're new to Perl, you should start with perlintro, which is a
18 general intro for beginners and provides some background to help you
19 navigate the rest of Perl's extensive documentation.
20
21 For ease of access, the Perl manual has been split up into several
22 sections.
23
24 Overview
25 perl Perl overview (this section)
26 perlintro Perl introduction for beginners
27 perltoc Perl documentation table of contents
28
29 Tutorials
30 perlreftut Perl references short introduction
31 perldsc Perl data structures intro
32 perllol Perl data structures: arrays of arrays
33
34 perlrequick Perl regular expressions quick start
35 perlretut Perl regular expressions tutorial
36
37 perlboot Perl OO tutorial for beginners
38 perltoot Perl OO tutorial, part 1
39 perltooc Perl OO tutorial, part 2
40 perlbot Perl OO tricks and examples
41
42 perlperf Perl Performance and Optimization Techniques
43
44 perlstyle Perl style guide
45
46 perlcheat Perl cheat sheet
47 perltrap Perl traps for the unwary
48 perldebtut Perl debugging tutorial
49
50 perlfaq Perl frequently asked questions
51 perlfaq1 General Questions About Perl
52 perlfaq2 Obtaining and Learning about Perl
53 perlfaq3 Programming Tools
54 perlfaq4 Data Manipulation
55 perlfaq5 Files and Formats
56 perlfaq6 Regexes
57 perlfaq7 Perl Language Issues
58 perlfaq8 System Interaction
59 perlfaq9 Networking
60
61 Reference Manual
62 perlsyn Perl syntax
63 perldata Perl data structures
64 perlop Perl operators and precedence
65 perlsub Perl subroutines
66 perlfunc Perl built-in functions
67 perlopentut Perl open() tutorial
68 perlpacktut Perl pack() and unpack() tutorial
69 perlpod Perl plain old documentation
70 perlpodspec Perl plain old documentation format specification
71 perlrun Perl execution and options
72 perldiag Perl diagnostic messages
73 perllexwarn Perl warnings and their control
74 perldebug Perl debugging
75 perlvar Perl predefined variables
76 perlre Perl regular expressions, the rest of the story
77 perlrebackslash Perl regular expression backslash sequences
78 perlrecharclass Perl regular expression character classes
79 perlreref Perl regular expressions quick reference
80 perlref Perl references, the rest of the story
81 perlform Perl formats
82 perlobj Perl objects
83 perltie Perl objects hidden behind simple variables
84 perldbmfilter Perl DBM filters
85
86 perlipc Perl interprocess communication
87 perlfork Perl fork() information
88 perlnumber Perl number semantics
89
90 perlthrtut Perl threads tutorial
91 perlothrtut Old Perl threads tutorial
92
93 perlport Perl portability guide
94 perllocale Perl locale support
95 perluniintro Perl Unicode introduction
96 perlunicode Perl Unicode support
97 perlunifaq Perl Unicode FAQ
98 perlunitut Perl Unicode tutorial
99 perlebcdic Considerations for running Perl on EBCDIC platforms
100
101 perlsec Perl security
102
103 perlmod Perl modules: how they work
104 perlmodlib Perl modules: how to write and use
105 perlmodstyle Perl modules: how to write modules with style
106 perlmodinstall Perl modules: how to install from CPAN
107 perlnewmod Perl modules: preparing a new module for distribution
108 perlpragma Perl modules: writing a user pragma
109
110 perlutil utilities packaged with the Perl distribution
111
112 perlcompile Perl compiler suite intro
113
114 perlfilter Perl source filters
115
116 perlglossary Perl Glossary
117
118 Internals and C Language Interface
119 perlembed Perl ways to embed perl in your C or C++ application
120 perldebguts Perl debugging guts and tips
121 perlxstut Perl XS tutorial
122 perlxs Perl XS application programming interface
123 perlclib Internal replacements for standard C library functions
124 perlguts Perl internal functions for those doing extensions
125 perlcall Perl calling conventions from C
126 perlmroapi Perl method resolution plugin interface
127 perlreapi Perl regular expression plugin interface
128 perlreguts Perl regular expression engine internals
129
130 perlapi Perl API listing (autogenerated)
131 perlintern Perl internal functions (autogenerated)
132 perliol C API for Perl's implementation of IO in Layers
133 perlapio Perl internal IO abstraction interface
134
135 perlhack Perl hackers guide
136 perlrepository Perl source repository
137
138 Miscellaneous
139 perlbook Perl book information
140 perlcommunity Perl community information
141 perltodo Perl things to do
142
143 perldoc Look up Perl documentation in Pod format
144
145 perlhist Perl history records
146 perldelta Perl changes since previous version
147 perl5100delta Perl changes in version 5.10.0
148 perl595delta Perl changes in version 5.9.5
149 perl594delta Perl changes in version 5.9.4
150 perl593delta Perl changes in version 5.9.3
151 perl592delta Perl changes in version 5.9.2
152 perl591delta Perl changes in version 5.9.1
153 perl590delta Perl changes in version 5.9.0
154 perl588delta Perl changes in version 5.8.8
155 perl589delta Perl changes in version 5.8.9
156 perl587delta Perl changes in version 5.8.7
157 perl586delta Perl changes in version 5.8.6
158 perl585delta Perl changes in version 5.8.5
159 perl584delta Perl changes in version 5.8.4
160 perl583delta Perl changes in version 5.8.3
161 perl582delta Perl changes in version 5.8.2
162 perl581delta Perl changes in version 5.8.1
163 perl58delta Perl changes in version 5.8.0
164 perl573delta Perl changes in version 5.7.3
165 perl572delta Perl changes in version 5.7.2
166 perl571delta Perl changes in version 5.7.1
167 perl570delta Perl changes in version 5.7.0
168 perl561delta Perl changes in version 5.6.1
169 perl56delta Perl changes in version 5.6
170 perl5005delta Perl changes in version 5.005
171 perl5004delta Perl changes in version 5.004
172
173 perlartistic Perl Artistic License
174 perlgpl GNU General Public License
175
176 Language-Specific
177 perlcn Perl for Simplified Chinese (in EUC-CN)
178 perljp Perl for Japanese (in EUC-JP)
179 perlko Perl for Korean (in EUC-KR)
180 perltw Perl for Traditional Chinese (in Big5)
181
182 Platform-Specific
183 perlaix Perl notes for AIX
184 perlamiga Perl notes for AmigaOS
185 perlapollo Perl notes for Apollo DomainOS
186 perlbeos Perl notes for BeOS
187 perlbs2000 Perl notes for POSIX-BC BS2000
188 perlce Perl notes for WinCE
189 perlcygwin Perl notes for Cygwin
190 perldgux Perl notes for DG/UX
191 perldos Perl notes for DOS
192 perlepoc Perl notes for EPOC
193 perlfreebsd Perl notes for FreeBSD
194 perlhaiku Perl notes for Haiku
195 perlhpux Perl notes for HP-UX
196 perlhurd Perl notes for Hurd
197 perlirix Perl notes for Irix
198 perllinux Perl notes for Linux
199 perlmachten Perl notes for Power MachTen
200 perlmacos Perl notes for Mac OS (Classic)
201 perlmacosx Perl notes for Mac OS X
202 perlmint Perl notes for MiNT
203 perlmpeix Perl notes for MPE/iX
204 perlnetware Perl notes for NetWare
205 perlopenbsd Perl notes for OpenBSD
206 perlos2 Perl notes for OS/2
207 perlos390 Perl notes for OS/390
208 perlos400 Perl notes for OS/400
209 perlplan9 Perl notes for Plan 9
210 perlqnx Perl notes for QNX
211 perlriscos Perl notes for RISC OS
212 perlsolaris Perl notes for Solaris
213 perlsymbian Perl notes for Symbian
214 perltru64 Perl notes for Tru64
215 perluts Perl notes for UTS
216 perlvmesa Perl notes for VM/ESA
217 perlvms Perl notes for VMS
218 perlvos Perl notes for Stratus VOS
219 perlwin32 Perl notes for Windows
220
221 By default, the manpages listed above are installed in the
222 /usr/share/man/ directory.
223
224 Extensive additional documentation for Perl modules is available. The
225 default configuration for perl will place this additional documentation
226 in the /usr/share/perl5 directory (or else in the man subdirectory of
227 the Perl library directory). Some of this additional documentation is
228 distributed standard with Perl, but you'll also find documentation for
229 third-party modules there.
230
231 You should be able to view Perl's documentation with your man(1)
232 program by including the proper directories in the appropriate start-up
233 files, or in the MANPATH environment variable. To find out where the
234 configuration has installed the manpages, type:
235
236 perl -V:man.dir
237
238 If the directories have a common stem, such as /usr/share/man/man1 and
239 /usr/share/man/man3, you need only to add that stem (/usr/share/man) to
240 your man(1) configuration files or your MANPATH environment variable.
241 If they do not share a stem, you'll have to add both stems.
242
243 If that doesn't work for some reason, you can still use the supplied
244 perldoc script to view module information. You might also look into
245 getting a replacement man program.
246
247 If something strange has gone wrong with your program and you're not
248 sure where you should look for help, try the -w switch first. It will
249 often point out exactly where the trouble is.
250
252 Perl is a language optimized for scanning arbitrary text files,
253 extracting information from those text files, and printing reports
254 based on that information. It's also a good language for many system
255 management tasks. The language is intended to be practical (easy to
256 use, efficient, complete) rather than beautiful (tiny, elegant,
257 minimal).
258
259 Perl combines (in the author's opinion, anyway) some of the best
260 features of C, sed, awk, and sh, so people familiar with those
261 languages should have little difficulty with it. (Language historians
262 will also note some vestiges of csh, Pascal, and even BASIC-PLUS.)
263 Expression syntax corresponds closely to C expression syntax. Unlike
264 most Unix utilities, Perl does not arbitrarily limit the size of your
265 data--if you've got the memory, Perl can slurp in your whole file as a
266 single string. Recursion is of unlimited depth. And the tables used
267 by hashes (sometimes called "associative arrays") grow as necessary to
268 prevent degraded performance. Perl can use sophisticated pattern
269 matching techniques to scan large amounts of data quickly. Although
270 optimized for scanning text, Perl can also deal with binary data, and
271 can make dbm files look like hashes. Setuid Perl scripts are safer
272 than C programs through a dataflow tracing mechanism that prevents many
273 stupid security holes.
274
275 If you have a problem that would ordinarily use sed or awk or sh, but
276 it exceeds their capabilities or must run a little faster, and you
277 don't want to write the silly thing in C, then Perl may be for you.
278 There are also translators to turn your sed and awk scripts into Perl
279 scripts.
280
281 But wait, there's more...
282
283 Begun in 1993 (see perlhist), Perl version 5 is nearly a complete
284 rewrite that provides the following additional benefits:
285
286 · modularity and reusability using innumerable modules
287
288 Described in perlmod, perlmodlib, and perlmodinstall.
289
290 · embeddable and extensible
291
292 Described in perlembed, perlxstut, perlxs, perlcall, perlguts, and
293 xsubpp.
294
295 · roll-your-own magic variables (including multiple simultaneous DBM
296 implementations)
297
298 Described in perltie and AnyDBM_File.
299
300 · subroutines can now be overridden, autoloaded, and prototyped
301
302 Described in perlsub.
303
304 · arbitrarily nested data structures and anonymous functions
305
306 Described in perlreftut, perlref, perldsc, and perllol.
307
308 · object-oriented programming
309
310 Described in perlobj, perlboot, perltoot, perltooc, and perlbot.
311
312 · support for light-weight processes (threads)
313
314 Described in perlthrtut and threads.
315
316 · support for Unicode, internationalization, and localization
317
318 Described in perluniintro, perllocale and Locale::Maketext.
319
320 · lexical scoping
321
322 Described in perlsub.
323
324 · regular expression enhancements
325
326 Described in perlre, with additional examples in perlop.
327
328 · enhanced debugger and interactive Perl environment, with integrated
329 editor support
330
331 Described in perldebtut, perldebug and perldebguts.
332
333 · POSIX 1003.1 compliant library
334
335 Described in POSIX.
336
337 Okay, that's definitely enough hype.
338
340 Perl is available for most operating systems, including virtually all
341 Unix-like platforms. See "Supported Platforms" in perlport for a
342 listing.
343
345 See perlrun.
346
348 Larry Wall <larry@wall.org>, with the help of oodles of other folks.
349
350 If your Perl success stories and testimonials may be of help to others
351 who wish to advocate the use of Perl in their applications, or if you
352 wish to simply express your gratitude to Larry and the Perl developers,
353 please write to perl-thanks@perl.org .
354
356 "@INC" locations of perl libraries
357
359 a2p awk to perl translator
360 s2p sed to perl translator
361
362 http://www.perl.org/ the Perl homepage
363 http://www.perl.com/ Perl articles (O'Reilly)
364 http://www.cpan.org/ the Comprehensive Perl Archive
365 http://www.pm.org/ the Perl Mongers
366
368 The "use warnings" pragma (and the -w switch) produces some lovely
369 diagnostics.
370
371 See perldiag for explanations of all Perl's diagnostics. The "use
372 diagnostics" pragma automatically turns Perl's normally terse warnings
373 and errors into these longer forms.
374
375 Compilation errors will tell you the line number of the error, with an
376 indication of the next token or token type that was to be examined.
377 (In a script passed to Perl via -e switches, each -e is counted as one
378 line.)
379
380 Setuid scripts have additional constraints that can produce error
381 messages such as "Insecure dependency". See perlsec.
382
383 Did we mention that you should definitely consider using the -w switch?
384
386 The -w switch is not mandatory.
387
388 Perl is at the mercy of your machine's definitions of various
389 operations such as type casting, atof(), and floating-point output with
390 sprintf().
391
392 If your stdio requires a seek or eof between reads and writes on a
393 particular stream, so does Perl. (This doesn't apply to sysread() and
394 syswrite().)
395
396 While none of the built-in data types have any arbitrary size limits
397 (apart from memory size), there are still a few arbitrary limits: a
398 given variable name may not be longer than 251 characters. Line
399 numbers displayed by diagnostics are internally stored as short
400 integers, so they are limited to a maximum of 65535 (higher numbers
401 usually being affected by wraparound).
402
403 You may mail your bug reports (be sure to include full configuration
404 information as output by the myconfig program in the perl source tree,
405 or by "perl -V") to perlbug@perl.org . If you've succeeded in
406 compiling perl, the perlbug script in the utils/ subdirectory can be
407 used to help mail in a bug report.
408
409 Perl actually stands for Pathologically Eclectic Rubbish Lister, but
410 don't tell anyone I said that.
411
413 The Perl motto is "There's more than one way to do it." Divining how
414 many more is left as an exercise to the reader.
415
416 The three principal virtues of a programmer are Laziness, Impatience,
417 and Hubris. See the Camel Book for why.
418
419
420
421perl v5.10.1 2017-03-22 PERL(1)