version 2, including all changes.
.
Rev |
Author |
# |
Line |
1 |
perry |
1 |
PERL |
|
|
2 |
!!!PERL |
|
|
3 |
NAME |
|
|
4 |
SYNOPSIS |
|
|
5 |
DESCRIPTION |
|
|
6 |
AVAILABILITY |
|
|
7 |
ENVIRONMENT |
|
|
8 |
AUTHOR |
|
|
9 |
FILES |
|
|
10 |
SEE ALSO |
|
|
11 |
DIAGNOSTICS |
|
|
12 |
BUGS |
|
|
13 |
NOTES |
|
|
14 |
---- |
|
|
15 |
!!NAME |
|
|
16 |
|
|
|
17 |
|
|
|
18 |
perl - Practical Extraction and Report Language |
|
|
19 |
!!SYNOPSIS |
|
|
20 |
|
|
|
21 |
|
|
|
22 |
__perl__ [[ __-sTuU__ ] [[ __-hv__ ] [[ |
|
|
23 |
__-V__[[:''configvar''] ] [[ __-cw__ ] [[ |
|
|
24 |
__-d__[[:''debugger''] ] [[ |
|
|
25 |
__-D__[[''number/list''] ] [[ __-pna__ ] [[ |
|
|
26 |
__-F__''pattern'' ] [[ __-l__[[''octal''] ] [[ |
|
|
27 |
__-0__[[''octal''] ] [[ __-I__''dir'' ] [[ |
|
|
28 |
__-m__[[__-__]''module'' ] [[ |
|
|
29 |
__-M__[[__-__]'''module...''' ] [[ __-P__ ] [[ |
|
|
30 |
__-S__ ] [[ __-x__[[''dir''] ] [[ |
|
|
31 |
__-i__[[''extension''] ] [[ __-e__ '''command''' ] |
|
|
32 |
[[ __--__ ] [[ ''programfile'' ] [[ ''argument'' |
|
|
33 |
]... |
|
|
34 |
|
|
|
35 |
|
|
|
36 |
For ease of access, the Perl manual has been split up into |
|
|
37 |
several sections: |
|
|
38 |
|
|
|
39 |
|
|
|
40 |
perl Perl overview (this section) |
|
|
41 |
perlfaq Perl frequently asked questions |
|
|
42 |
perltoc Perl documentation table of contents |
|
|
43 |
perlbook Perl book information |
|
|
44 |
perlsyn Perl syntax |
|
|
45 |
perldata Perl data structures |
|
|
46 |
perlop Perl operators and precedence |
|
|
47 |
perlsub Perl subroutines |
|
|
48 |
perlfunc Perl builtin functions |
|
|
49 |
perlreftut Perl references short introduction |
|
|
50 |
perldsc Perl data structures intro |
|
|
51 |
perlrequick Perl regular expressions quick start |
|
|
52 |
perlpod Perl plain old documentation |
|
|
53 |
perlstyle Perl style guide |
|
|
54 |
perltrap Perl traps for the unwary |
|
|
55 |
perlrun Perl execution and options |
|
|
56 |
perldiag Perl diagnostic messages |
|
|
57 |
perllexwarn Perl warnings and their control |
|
|
58 |
perldebtut Perl debugging tutorial |
|
|
59 |
perldebug Perl debugging |
|
|
60 |
perlvar Perl predefined variables |
|
|
61 |
perllol Perl data structures: arrays of arrays |
|
|
62 |
perlopentut Perl open() tutorial |
|
|
63 |
perlretut Perl regular expressions tutorial |
|
|
64 |
perlre Perl regular expressions, the rest of the story |
|
|
65 |
perlref Perl references, the rest of the story |
|
|
66 |
perlform Perl formats |
|
|
67 |
perlboot Perl OO tutorial for beginners |
|
|
68 |
perltoot Perl OO tutorial, part 1 |
|
|
69 |
perltootc Perl OO tutorial, part 2 |
|
|
70 |
perlobj Perl objects |
|
|
71 |
perlbot Perl OO tricks and examples |
|
|
72 |
perltie Perl objects hidden behind simple variables |
|
|
73 |
perlipc Perl interprocess communication |
|
|
74 |
perlfork Perl fork() information |
|
|
75 |
perlnumber Perl number semantics |
|
|
76 |
perlthrtut Perl threads tutorial |
|
|
77 |
perlport Perl portability guide |
|
|
78 |
perllocale Perl locale support |
|
|
79 |
perlunicode Perl unicode support |
|
|
80 |
perlebcdic Considerations for running Perl on EBCDIC platforms |
|
|
81 |
perlsec Perl security |
|
|
82 |
perlmod Perl modules: how they work |
|
|
83 |
perlmodlib Perl modules: how to write and use |
|
|
84 |
perlmodinstall Perl modules: how to install from CPAN |
|
|
85 |
perlnewmod Perl modules: preparing a new module for distribution |
|
|
86 |
perlfaq1 General Questions About Perl |
|
|
87 |
perlfaq2 Obtaining and Learning about Perl |
|
|
88 |
perlfaq3 Programming Tools |
|
|
89 |
perlfaq4 Data Manipulation |
|
|
90 |
perlfaq5 Files and Formats |
|
|
91 |
perlfaq6 Regexes |
|
|
92 |
perlfaq7 Perl Language Issues |
|
|
93 |
perlfaq8 System Interaction |
|
|
94 |
perlfaq9 Networking |
|
|
95 |
perlcompile Perl compiler suite intro |
|
|
96 |
perlembed Perl ways to embed perl in your C or C++ application |
|
|
97 |
perldebguts Perl debugging guts and tips |
|
|
98 |
perlxstut Perl XS tutorial |
|
|
99 |
perlxs Perl XS application programming interface |
|
|
100 |
perlclib Internal replacements for standard C library functions |
|
|
101 |
perlguts Perl internal functions for those doing extensions |
|
|
102 |
perlcall Perl calling conventions from C |
|
|
103 |
perlutil utilities packaged with the Perl distribution |
|
|
104 |
perlfilter Perl source filters (package: libfilter-perl) |
|
|
105 |
perldbmfilter Perl DBM filters |
|
|
106 |
perlapi Perl API listing (autogenerated) |
|
|
107 |
perlintern Perl internal functions (autogenerated) |
|
|
108 |
perlapio Perl internal IO abstraction interface |
|
|
109 |
perltodo Perl things to do |
|
|
110 |
perlhack Perl hackers guide |
|
|
111 |
perlhist Perl history records |
|
|
112 |
perldelta Perl changes since previous version |
|
|
113 |
perl5005delta Perl changes in version 5.005 |
|
|
114 |
perl5004delta Perl changes in version 5.004 |
|
|
115 |
perlaix Perl notes for AIX |
|
|
116 |
perlamiga Perl notes for Amiga |
|
|
117 |
perlbs2000 Perl notes for POSIX-BC BS2000 |
|
|
118 |
perlcygwin Perl notes for Cygwin |
|
|
119 |
perldos Perl notes for DOS |
|
|
120 |
perlepoc Perl notes for EPOC |
|
|
121 |
perlhpux Perl notes for HP-UX |
2 |
perry |
122 |
perlmachten Perl notes for Power !MachTen |
1 |
perry |
123 |
perlmacos Perl notes for Mac OS (Classic) |
|
|
124 |
perlmpeix Perl notes for MPE/iX |
|
|
125 |
perlos2 Perl notes for OS/2 |
|
|
126 |
perlos390 Perl notes for OS/390 |
|
|
127 |
perlsolaris Perl notes for Solaris |
|
|
128 |
perlvmesa Perl notes for VM/ESA |
|
|
129 |
perlvms Perl notes for VMS |
|
|
130 |
perlvos Perl notes for Stratus VOS |
|
|
131 |
perlwin32 Perl notes for Windows |
|
|
132 |
(If you're intending to read these straight through for the first time, the suggested order will tend to reduce the number of forward references.) |
|
|
133 |
|
|
|
134 |
|
|
|
135 |
On Debian systems, you need to install the __perl-doc__ |
|
|
136 |
package which contains the majority of the standard Perl |
|
|
137 |
documentation and the ''perldoc'' program. |
|
|
138 |
|
|
|
139 |
|
|
|
140 |
Extensive additional documentation for Perl modules is |
|
|
141 |
available, both those distributed with Perl and third-party |
|
|
142 |
modules which are packaged or locally |
|
|
143 |
installed. |
|
|
144 |
|
|
|
145 |
|
|
|
146 |
You should be able to view Perl's documentation with your |
|
|
147 |
man(1) program or perldoc(1). |
|
|
148 |
|
|
|
149 |
|
|
|
150 |
If something strange has gone wrong with your program and |
|
|
151 |
you're not sure where you should look for help, try the |
|
|
152 |
__-w__ switch first. It will often point out exactly |
|
|
153 |
where the trouble is. |
|
|
154 |
!!DESCRIPTION |
|
|
155 |
|
|
|
156 |
|
|
|
157 |
Perl is a language optimized for scanning arbitrary text |
|
|
158 |
files, extracting information from those text files, and |
|
|
159 |
printing reports based on that information. It's also a good |
|
|
160 |
language for many system management tasks. The language is |
|
|
161 |
intended to be practical (easy to use, efficient, complete) |
|
|
162 |
rather than beautiful (tiny, elegant, minimal). |
|
|
163 |
|
|
|
164 |
|
|
|
165 |
Perl combines (in the author's opinion, anyway) some of the |
|
|
166 |
best features of C, __sed__, __awk__, and __sh__, |
|
|
167 |
so people familiar with those languages should have little |
|
|
168 |
difficulty with it. (Language historians will also note some |
|
|
169 |
vestiges of __csh__, Pascal, and even |
|
|
170 |
BASIC-PLUS .) Expression syntax corresponds |
|
|
171 |
closely to C expression syntax. Unlike most Unix utilities, |
|
|
172 |
Perl does not arbitrarily limit the size of your data--if |
|
|
173 |
you've got the memory, Perl can slurp in your whole file as |
|
|
174 |
a single string. Recursion is of unlimited depth. And the |
|
|
175 |
tables used by hashes (sometimes called ``associative |
|
|
176 |
arrays'') grow as necessary to prevent degraded performance. |
|
|
177 |
Perl can use sophisticated pattern matching techniques to |
|
|
178 |
scan large amounts of data quickly. Although optimized for |
|
|
179 |
scanning text, Perl can also deal with binary data, and can |
|
|
180 |
make dbm files look like hashes. Setuid Perl scripts are |
|
|
181 |
safer than C programs through a dataflow tracing mechanism |
|
|
182 |
that prevents many stupid security holes. |
|
|
183 |
|
|
|
184 |
|
|
|
185 |
If you have a problem that would ordinarily use __sed__ |
|
|
186 |
or __awk__ or __sh__, but it exceeds their |
|
|
187 |
capabilities or must run a little faster, and you don't want |
|
|
188 |
to write the silly thing in C, then Perl may be for you. |
|
|
189 |
There are also translators to turn your __sed__ and |
|
|
190 |
__awk__ scripts into Perl scripts. |
|
|
191 |
|
|
|
192 |
|
|
|
193 |
But wait, there's more... |
|
|
194 |
|
|
|
195 |
|
|
|
196 |
Begun in 1993 (see perlhist), Perl version 5 is nearly a |
|
|
197 |
complete rewrite that provides the following additional |
|
|
198 |
benefits: |
|
|
199 |
|
|
|
200 |
|
|
|
201 |
modularity and reusability using innumerable |
|
|
202 |
modules |
|
|
203 |
|
|
|
204 |
|
|
|
205 |
Described in perlmod, perlmodlib, and |
|
|
206 |
perlmodinstall. |
|
|
207 |
|
|
|
208 |
|
|
|
209 |
embeddable and extensible |
|
|
210 |
|
|
|
211 |
|
|
|
212 |
Described in perlembed, perlxstut, perlxs, perlcall, |
|
|
213 |
perlguts, and xsubpp. |
|
|
214 |
|
|
|
215 |
|
|
|
216 |
roll-your-own magic variables (including multiple |
|
|
217 |
simultaneous DBM |
|
|
218 |
implementations) |
|
|
219 |
|
|
|
220 |
|
|
|
221 |
Described in perltie and AnyDBM_File. |
|
|
222 |
|
|
|
223 |
|
|
|
224 |
subroutines can now be overridden, autoloaded, and |
|
|
225 |
prototyped |
|
|
226 |
|
|
|
227 |
|
|
|
228 |
Described in perlsub. |
|
|
229 |
|
|
|
230 |
|
|
|
231 |
arbitrarily nested data structures and anonymous |
|
|
232 |
functions |
|
|
233 |
|
|
|
234 |
|
|
|
235 |
Described in perlreftut, perlref, perldsc, and |
|
|
236 |
perllol. |
|
|
237 |
|
|
|
238 |
|
|
|
239 |
object-oriented programming |
|
|
240 |
|
|
|
241 |
|
|
|
242 |
Described in perlobj, perltoot, and perlbot. |
|
|
243 |
|
|
|
244 |
|
|
|
245 |
compilability into C code or Perl bytecode |
|
|
246 |
|
|
|
247 |
|
|
|
248 |
Described in B and B::Bytecode. |
|
|
249 |
|
|
|
250 |
|
|
|
251 |
support for light-weight processes (threads) |
|
|
252 |
|
|
|
253 |
|
|
|
254 |
Described in perlthrtut and Thread. |
|
|
255 |
|
|
|
256 |
|
|
|
257 |
support for internationalization, localization, and |
|
|
258 |
Unicode |
|
|
259 |
|
|
|
260 |
|
|
|
261 |
Described in perllocale and utf8. |
|
|
262 |
|
|
|
263 |
|
|
|
264 |
lexical scoping |
|
|
265 |
|
|
|
266 |
|
|
|
267 |
Described in perlsub. |
|
|
268 |
|
|
|
269 |
|
|
|
270 |
regular expression enhancements |
|
|
271 |
|
|
|
272 |
|
|
|
273 |
Described in perlre, with additional examples in |
|
|
274 |
perlop. |
|
|
275 |
|
|
|
276 |
|
|
|
277 |
enhanced debugger and interactive Perl environment, with |
|
|
278 |
integrated editor support |
|
|
279 |
|
|
|
280 |
|
|
|
281 |
Described in perldebug. |
|
|
282 |
|
|
|
283 |
|
|
|
284 |
POSIX 1003.1 compliant library |
|
|
285 |
|
|
|
286 |
|
|
|
287 |
Described in POSIX . |
|
|
288 |
|
|
|
289 |
|
|
|
290 |
Okay, that's ''definitely'' enough hype. |
|
|
291 |
!!AVAILABILITY |
|
|
292 |
|
|
|
293 |
|
|
|
294 |
Perl is available for most operating systems, including |
|
|
295 |
virtually all Unix-like platforms. See ``Supported |
|
|
296 |
Platforms'' in perlport for a listing. |
|
|
297 |
!!ENVIRONMENT |
|
|
298 |
|
|
|
299 |
|
|
|
300 |
See perlrun. |
|
|
301 |
!!AUTHOR |
|
|
302 |
|
|
|
303 |
|
|
|
304 |
Larry Wall |
|
|
305 |
|
|
|
306 |
|
|
|
307 |
If your Perl success stories and testimonials may be of help |
|
|
308 |
to others who wish to advocate the use of Perl in their |
|
|
309 |
applications, or if you wish to simply express your |
|
|
310 |
gratitude to Larry and the Perl developers, please write to |
|
|
311 |
perl-thanks@perl.org . |
|
|
312 |
!!FILES |
|
|
313 |
|
|
|
314 |
|
|
|
315 |
|
|
|
316 |
!!SEE ALSO |
|
|
317 |
|
|
|
318 |
|
|
|
319 |
a2p awk to perl translator |
|
|
320 |
s2p sed to perl translator |
|
|
321 |
http://www.perl.com/ the Perl Home Page |
|
|
322 |
http://www.perl.com/CPAN the Comprehensive Perl Archive |
|
|
323 |
!!DIAGNOSTICS |
|
|
324 |
|
|
|
325 |
|
|
|
326 |
The use warnings pragma (and the __-w__ switch) |
|
|
327 |
produces some lovely diagnostics. |
|
|
328 |
|
|
|
329 |
|
|
|
330 |
See perldiag for explanations of all Perl's diagnostics. The |
|
|
331 |
use diagnostics pragma automatically turns Perl's |
|
|
332 |
normally terse warnings and errors into these longer |
|
|
333 |
forms. |
|
|
334 |
|
|
|
335 |
|
|
|
336 |
Compilation errors will tell you the line number of the |
|
|
337 |
error, with an indication of the next token or token type |
|
|
338 |
that was to be examined. (In a script passed to Perl via |
|
|
339 |
__-e__ switches, each __-e__ is counted as one |
|
|
340 |
line.) |
|
|
341 |
|
|
|
342 |
|
|
|
343 |
Setuid scripts have additional constraints that can produce |
|
|
344 |
error messages such as ``Insecure dependency''. See |
|
|
345 |
perlsec. |
|
|
346 |
|
|
|
347 |
|
|
|
348 |
Did we mention that you should definitely consider using the |
|
|
349 |
__-w__ switch? |
|
|
350 |
!!BUGS |
|
|
351 |
|
|
|
352 |
|
|
|
353 |
The __-w__ switch is not mandatory. |
|
|
354 |
|
|
|
355 |
|
|
|
356 |
Perl is at the mercy of your machine's definitions of |
|
|
357 |
various operations such as type casting, ''atof()'', and |
|
|
358 |
floating-point output with ''sprintf()''. |
|
|
359 |
|
|
|
360 |
|
|
|
361 |
If your stdio requires a seek or eof between reads and |
|
|
362 |
writes on a particular stream, so does Perl. (This doesn't |
|
|
363 |
apply to ''sysread()'' and |
|
|
364 |
''syswrite()''.) |
|
|
365 |
|
|
|
366 |
|
|
|
367 |
While none of the built-in data types have any arbitrary |
|
|
368 |
size limits (apart from memory size), there are still a few |
|
|
369 |
arbitrary limits: a given variable name may not be longer |
|
|
370 |
than 251 characters. Line numbers displayed by diagnostics |
|
|
371 |
are internally stored as short integers, so they are limited |
|
|
372 |
to a maximum of 65535 (higher numbers usually being affected |
|
|
373 |
by wraparound). |
|
|
374 |
|
|
|
375 |
|
|
|
376 |
You may mail your bug reports (be sure to include full |
|
|
377 |
configuration information as output by the myconfig program |
|
|
378 |
in the perl source tree, or by perl -V) to |
|
|
379 |
perlbug@perl.org . If you've succeeded in compiling perl, |
|
|
380 |
the __perlbug__ script in the ''utils/'' subdirectory |
|
|
381 |
can be used to help mail in a bug report. |
|
|
382 |
|
|
|
383 |
|
|
|
384 |
Perl actually stands for Pathologically Eclectic Rubbish |
|
|
385 |
Lister, but don't tell anyone I said that. |
|
|
386 |
!!NOTES |
|
|
387 |
|
|
|
388 |
|
|
|
389 |
The Perl motto is ``There's more than one way to do it.'' |
|
|
390 |
Divining how many more is left as an exercise to the |
|
|
391 |
reader. |
|
|
392 |
|
|
|
393 |
|
|
|
394 |
The three principal virtues of a programmer are Laziness, |
|
|
395 |
Impatience, and Hubris. See the Camel Book for |
|
|
396 |
why. |
|
|
397 |
---- |