Debian Codegraph @

upstream/opensuse-tumbleweed/man1/perlrun.1

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\"
56 .\" Required to disable full justification in groff 1.23.0.
57 .if n .ds AD l
58 .\" ========================================================================
59 .\"
60 .IX Title "PERLRUN 1"
61 .TH PERLRUN 1 2026-03-09 "perl v5.42.1" "Perl Programmers Reference Guide"
62 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
63 .\" way too many mistakes in technical documents.
64 .if n .ad l
65 .nh
66 .SH NAME
67 perlrun \- how to execute the Perl interpreter
68 .SH SYNOPSIS
69 .IX Header "SYNOPSIS"
70 \&\fBperl\fR [\ \fB\-gsTtuUWX\fR\ ]
71 [\ \fB\-h?v\fR\ ]\ [\ \fB\-V\fR[:\fIconfigvar\fR]\ ]
72 [\ \fB\-cw\fR\ ]\ [\ \fB\-d\fR[\fBt\fR][:\fIdebugger\fR]\ ]\ [\ \fB\-D\fR[\fInumber/list\fR]\ ]
73 [\ \fB\-pna\fR\ ]\ [\ \fB\-F\fR\fIpattern\fR\ ]\ [\ \fB\-l\fR[\fIoctal\fR]\ ]\ [\ \fB\-0\fR[\fIoctal/hexadecimal\fR]\ ]
74 [\ \fB\-I\fR\fIdir\fR\ ]\ [\ \fB\-m\fR[\fB\-\fR]\fImodule\fR\ ]\ [\ \fB\-M\fR[\fB\-\fR]\fI\*(Aqmodule...\*(Aq\fR\ ]\ [\ \fB\-f\fR\ ]
75 [\ \fB\-C\ [\fR\f(BInumber/list\fR\fB]\ \fR]
76 [\ \fB\-S\fR\ ]
77 [\ \fB\-x\fR[\fIdir\fR]\ ]
78 [\ \fB\-i\fR[\fIextension\fR]\ ]
79 [\ [\fB\-e\fR|\fB\-E\fR]\ \fI\*(Aqcommand\*(Aq\fR\ ]\ [\ \fB\-\-\fR\ ]\ [\ \fIprogramfile\fR\ ]\ [\ \fIargument\fR\ ]...
80 .SH DESCRIPTION
81 .IX Header "DESCRIPTION"
82 The normal way to run a Perl program is by making it directly
83 executable, or else by passing the name of the source file as an
84 argument on the command line. (An interactive Perl environment
85 is also possible\-\-see perldebug for details on how to do that.)
86 Upon startup, Perl looks for your program in one of the following
87 places:
88 .IP 1. 4
89 Specified line by line via \-e or \-E
90 switches on the command line.
91 .IP 2. 4
92 Contained in the file specified by the first filename on the command line.
93 (Note that systems supporting the \f(CW\*(C`#!\*(C'\fR notation invoke interpreters this
94 way. See "Location of Perl".)
95 .IP 3. 4
96 Passed in implicitly via standard input. This works only if there are
97 no filename arguments\-\-to pass arguments to a STDIN\-read program you
98 must explicitly specify a "\-" for the program name.
99 .PP
100 With methods 2 and 3, Perl starts parsing the input file from the
101 beginning, unless you\*(Aqve specified a "\-x" switch, in which case it
102 scans for the first line starting with \f(CW\*(C`#!\*(C'\fR and containing the word
103 "perl", and starts there instead. This is useful for running a program
104 embedded in a larger message. (In this case you would indicate the end
105 of the program using the \f(CW\*(C`_\|_END_\|_\*(C'\fR token.)
106 .PP
107 The \f(CW\*(C`#!\*(C'\fR line is always examined for switches as the line is being
108 parsed. Thus, if you\*(Aqre on a machine that allows only one argument
109 with the \f(CW\*(C`#!\*(C'\fR line, or worse, doesn\*(Aqt even recognize the \f(CW\*(C`#!\*(C'\fR line, you
110 still can get consistent switch behaviour regardless of how Perl was
111 invoked, even if "\-x" was used to find the beginning of the program.
112 .PP
113 Because historically some operating systems silently chopped off
114 kernel interpretation of the \f(CW\*(C`#!\*(C'\fR line after 32 characters, some
115 switches may be passed in on the command line, and some may not;
116 you could even get a "\-" without its letter, if you\*(Aqre not careful.
117 You probably want to make sure that all your switches fall either
118 before or after that 32\-character boundary. Most switches don\*(Aqt
119 actually care if they\*(Aqre processed redundantly, but getting a "\-"
120 instead of a complete switch could cause Perl to try to execute
121 standard input instead of your program. And a partial \-I
122 switch could also cause odd results.
123 .PP
124 Some switches do care if they are processed twice, for instance
125 combinations of \-l and \-0.
126 Either put all the switches after the 32\-character boundary (if
127 applicable), or replace the use of \fB\-0\fR\fIdigits\fR by
128 \&\f(CW\*(C`BEGIN{ $/ = "\e0digits"; }\*(C'\fR.
129 .PP
130 Parsing of the \f(CW\*(C`#!\*(C'\fR switches starts wherever "perl" is mentioned in the line.
131 The sequences "\-*" and "\- " are specifically ignored so that you could,
132 if you were so inclined, say
133 .PP
134 .Vb 4
135 \& #!/bin/sh
136 \& #! \-*\- perl \-*\- \-p
137 \& eval \*(Aqexec perl \-x \-wS $0 ${1+"$@"}\*(Aq
138 \& if 0;
139 .Ve
140 .PP
141 to let Perl see the "\-p" switch.
142 .PP
143 A similar trick involves the \fIenv\fR program, if you have it.
144 .PP
145 .Vb 1
146 \& #!/usr/bin/env perl
147 .Ve
148 .PP
149 The examples above use a relative path to the perl interpreter,
150 getting whatever version is first in the user\*(Aqs path. If you want
151 a specific version of Perl, say, perl5.14.1, you should place
152 that directly in the \f(CW\*(C`#!\*(C'\fR line\*(Aqs path.
153 .PP
154 If the \f(CW\*(C`#!\*(C'\fR line does not contain the word "perl" nor the word "indir",
155 the program named after the \f(CW\*(C`#!\*(C'\fR is executed instead of the Perl
156 interpreter. This is slightly bizarre, but it helps people on machines
157 that don\*(Aqt do \f(CW\*(C`#!\*(C'\fR, because they can tell a program that their SHELL is
158 \&\fI/usr/bin/perl\fR, and Perl will then dispatch the program to the correct
159 interpreter for them.
160 .PP
161 After locating your program, Perl compiles the entire program to an
162 internal form. If there are any compilation errors, execution of the
163 program is not attempted. (This is unlike the typical shell script,
164 which might run part\-way through before finding a syntax error.)
165 .PP
166 If the program is syntactically correct, it is executed. If the program
167 runs off the end without hitting an \fBexit()\fR or \fBdie()\fR operator, an implicit
168 \&\f(CWexit(0)\fR is provided to indicate successful completion.
169 .SS "#! and quoting on non\-Unix systems"
170 .IX Xref "hashbang #!"
171 .IX Subsection "#! and quoting on non-Unix systems"
172 Unix\*(Aqs \f(CW\*(C`#!\*(C'\fR technique can be simulated on other systems:
173 .IP OS/2 4
174 .IX Item "OS/2"
175 Put
176 .Sp
177 .Vb 1
178 \& extproc perl \-S \-your_switches
179 .Ve
180 .Sp
181 as the first line in \f(CW\*(C`*.cmd\*(C'\fR file ("\-S" due to a bug in cmd.exe\*(Aqs
182 \&\`extproc\*(Aq handling).
183 .IP MS\-DOS 4
184 .IX Item "MS-DOS"
185 Create a batch file to run your program, and codify it in
186 \&\f(CW\*(C`ALTERNATE_SHEBANG\*(C'\fR (see the \fIdosish.h\fR file in the source
187 distribution for more information).
188 .IP Win95/NT 4
189 .IX Item "Win95/NT"
190 The Win95/NT installation, when using the ActiveState installer for Perl,
191 will modify the Registry to associate the \fI.pl\fR extension with the perl
192 interpreter. If you install Perl by other means (including building from
193 the sources), you may have to modify the Registry yourself. Note that
194 this means you can no longer tell the difference between an executable
195 Perl program and a Perl library file.
196 .IP VMS 4
197 .IX Item "VMS"
198 Put
199 .Sp
200 .Vb 2
201 \& $ perl \-mysw \*(Aqf$env("procedure")\*(Aq \*(Aqp1\*(Aq \*(Aqp2\*(Aq \*(Aqp3\*(Aq \*(Aqp4\*(Aq \*(Aqp5\*(Aq \*(Aqp6\*(Aq \*(Aqp7\*(Aq \*(Aqp8\*(Aq !
202 \& $ exit++ + ++$status != 0 and $exit = $status = undef;
203 .Ve
204 .Sp
205 at the top of your program, where \fB\-mysw\fR are any command line switches you
206 want to pass to Perl. You can now invoke the program directly, by saying
207 \&\f(CW\*(C`perl program\*(C'\fR, or as a DCL procedure, by saying \f(CW@program\fR (or implicitly
208 via \fIDCL$PATH\fR by just using the name of the program).
209 .Sp
210 This incantation is a bit much to remember, but Perl will display it for
211 you if you say \f(CW\*(C`perl "\-V:startperl"\*(C'\fR.
212 .PP
213 Command\-interpreters on non\-Unix systems have rather different ideas
214 on quoting than Unix shells. You\*(Aqll need to learn the special
215 characters in your command\-interpreter (\f(CW\*(C`*\*(C'\fR, \f(CW\*(C`\e\*(C'\fR and \f(CW\*(C`"\*(C'\fR are
216 common) and how to protect whitespace and these characters to run
217 one\-liners (see \-e below).
218 .PP
219 On some systems, you may have to change single\-quotes to double ones,
220 which you must \fInot\fR do on Unix or Plan 9 systems. You might also
221 have to change a single % to a %%.
222 .PP
223 For example:
224 .PP
225 .Vb 2
226 \& # Unix
227 \& perl \-e \*(Aqprint "Hello world\en"\*(Aq
228 \&
229 \& # MS\-DOS, etc.
230 \& perl \-e "print \e"Hello world\en\e""
231 \&
232 \& # VMS
233 \& perl \-e "print ""Hello world\en"""
234 .Ve
235 .PP
236 The problem is that none of this is reliable: it depends on the
237 command and it is entirely possible neither works. If \fI4DOS\fR were
238 the command shell, this would probably work better:
239 .PP
240 .Vb 1
241 \& perl \-e "print <Ctrl\-x>"Hello world\en<Ctrl\-x>""
242 .Ve
243 .PP
244 \&\fBCMD.EXE\fR in Windows NT slipped a lot of standard Unix functionality in
245 when nobody was looking, but just try to find documentation for its
246 quoting rules.
247 .PP
248 There is no general solution to all of this. It\*(Aqs just a mess.
249 .SS "Location of Perl"
250 .IX Xref "perl, location of interpreter"
251 .IX Subsection "Location of Perl"
252 It may seem obvious to say, but Perl is useful only when users can
253 easily find it. When possible, it\*(Aqs good for both \fI/usr/bin/perl\fR
254 and \fI/usr/local/bin/perl\fR to be symlinks to the actual binary. If
255 that can\*(Aqt be done, system administrators are strongly encouraged
256 to put (symlinks to) perl and its accompanying utilities into a
257 directory typically found along a user\*(Aqs PATH, or in some other
258 obvious and convenient place.
259 .PP
260 In this documentation, \f(CW\*(C`#!/usr/bin/perl\*(C'\fR on the first line of the program
261 will stand in for whatever method works on your system. You are
262 advised to use a specific path if you care about a specific version.
263 .PP
264 .Vb 1
265 \& #!/usr/local/bin/perl5.14
266 .Ve
267 .PP
268 or if you just want to be running at least version, place a statement
269 like this at the top of your program:
270 .PP
271 .Vb 1
272 \& use v5.14;
273 .Ve
274 .SS "Command Switches"
275 .IX Xref "perl, command switches command switches"
276 .IX Subsection "Command Switches"
277 As with all standard commands, a single\-character switch may be
278 clustered with the following switch, if any.
279 .PP
280 .Vb 1
281 \& #!/usr/bin/perl \-spi.orig # same as \-s \-p \-i.orig
282 .Ve
283 .PP
284 A \f(CW\*(C`\-\-\*(C'\fR signals the end of options and disables further option processing. Any
285 arguments after the \f(CW\*(C`\-\-\*(C'\fR are treated as filenames and arguments.
286 .PP
287 Switches include:
288 .IP \fB\-0\fR[\fIoctal/hexadecimal\fR] 5
289 .IX Xref "-0 $"
290 .IX Item "-0[octal/hexadecimal]"
291 specifies the input record separator (\f(CW$/\fR) as an octal or
292 hexadecimal number. If there are no digits, the null character is the
293 separator. Other switches may precede or follow the digits. For
294 example, if you have a version of \fIfind\fR which can print filenames
295 terminated by the null character, you can say this:
296 .Sp
297 .Vb 1
298 \& find . \-name \*(Aq*.orig\*(Aq \-print0 | perl \-n0e unlink
299 .Ve
300 .Sp
301 The special value 00 will cause Perl to slurp files in paragraph mode.
302 .Sp
303 Any value 0400 or above will cause Perl to slurp files whole, but by convention
304 the value 0777 is the one normally used for this purpose. The "\-g" flag
305 is a simpler alias for it.
306 .Sp
307 You can also specify the separator character using hexadecimal notation:
308 \&\fB\-0x\fR\f(BIHHH...\fR, where the \f(CW\*(C`\fR\f(CIH\fR\f(CW\*(C'\fR are valid hexadecimal digits. Unlike
309 the octal form, this one may be used to specify any Unicode character, even
310 those beyond 0xFF. So if you \fIreally\fR want a record separator of 0777,
311 specify it as \fB\-0x1FF\fR. (This means that you cannot use the "\-x" option
312 with a directory name that consists of hexadecimal digits, or else Perl
313 will think you have specified a hex number to \fB\-0\fR.)
314 .IP \fB\-a\fR 5
315 .IX Xref "-a autosplit"
316 .IX Item "-a"
317 turns on autosplit mode when used with a "\-n" or "\-p". An implicit
318 split command to the \f(CW@F\fR array is done as the first thing inside the
319 implicit while loop produced by the "\-n" or "\-p".
320 .Sp
321 .Vb 1
322 \& perl \-ane \*(Aqprint pop(@F), "\en";\*(Aq
323 .Ve
324 .Sp
325 is equivalent to
326 .Sp
327 .Vb 4
328 \& while (<>) {
329 \& @F = split(\*(Aq \*(Aq);
330 \& print pop(@F), "\en";
331 \& }
332 .Ve
333 .Sp
334 An alternate delimiter may be specified using \-F.
335 .Sp
336 \&\fB\-a\fR implicitly sets "\-n".
337 .IP "\fB\-C [\fR\f(BInumber/list\fR\fB]\fR" 5
338 .IX Xref "-C"
339 .IX Item "-C [number/list]"
340 The \fB\-C\fR flag controls some of the Perl Unicode features.
341 .Sp
342 As of 5.8.1, the \fB\-C\fR can be followed either by a number or a list
343 of option letters. The letters, their numeric values, and effects
344 are as follows; listing the letters is equal to summing the numbers.
345 .Sp
346 .Vb 10
347 \& I 1 STDIN is assumed to be in UTF\-8
348 \& O 2 STDOUT will be in UTF\-8
349 \& E 4 STDERR will be in UTF\-8
350 \& S 7 I + O + E
351 \& i 8 UTF\-8 is the default PerlIO layer for input streams
352 \& o 16 UTF\-8 is the default PerlIO layer for output streams
353 \& D 24 i + o
354 \& A 32 the @ARGV elements are expected to be strings encoded
355 \& in UTF\-8
356 \& L 64 normally the "IOEioA" are unconditional, the L makes
357 \& them conditional on the locale environment variables
358 \& (the LC_ALL, LC_CTYPE, and LANG, in the order of
359 \& decreasing precedence) \-\- if the variables indicate
360 \& UTF\-8, then the selected "IOEioA" are in effect
361 \& a 256 Set ${^UTF8CACHE} to \-1, to run the UTF\-8 caching
362 \& code in debugging mode.
363 .Ve
364 .Sp
365 For example, \fB\-COE\fR and \fB\-C6\fR will both turn on UTF\-8\-ness on both
366 STDOUT and STDERR. Repeating letters is just redundant, not cumulative
367 nor toggling.
368 .Sp
369 The \f(CW\*(C`io\*(C'\fR options mean that any subsequent \fBopen()\fR (or similar I/O
370 operations) in main program scope will have the \f(CW\*(C`:utf8\*(C'\fR PerlIO layer
371 implicitly applied to them, in other words, UTF\-8 is expected from any
372 input stream, and UTF\-8 is produced to any output stream. This is just
373 the default set via \f(CW\*(C`${^OPEN}\*(C'\fR,
374 with explicit layers in \fBopen()\fR and with \fBbinmode()\fR one can
375 manipulate streams as usual. This has no effect on code run in modules.
376 .Sp
377 \&\fB\-C\fR on its own (not followed by any number or option list), or the
378 empty string \f(CW""\fR for the "PERL_UNICODE" environment variable, has the
379 same effect as \fB\-CSDL\fR. In other words, the standard I/O handles and
380 the default \f(CWopen()\fR layer are UTF\-8\-fied \fIbut\fR only if the locale
381 environment variables indicate a UTF\-8 locale. This behaviour follows
382 the \fIimplicit\fR (and problematic) UTF\-8 behaviour of Perl 5.8.0.
383 (See "UTF\-8 no longer default under UTF\-8 locales" in perl581delta.)
384 .Sp
385 You can use \fB\-C0\fR (or \f(CW"0"\fR for \f(CW\*(C`PERL_UNICODE\*(C'\fR) to explicitly
386 disable all the above Unicode features.
387 .Sp
388 The read\-only magic variable \f(CW\*(C`${^UNICODE}\*(C'\fR reflects the numeric value
389 of this setting. This variable is set during Perl startup and is
390 thereafter read\-only. If you want runtime effects, use the three\-arg
391 \&\fBopen()\fR (see "open" in perlfunc), the two\-arg \fBbinmode()\fR (see "binmode" in perlfunc),
392 and the \f(CW\*(C`open\*(C'\fR pragma (see open).
393 .Sp
394 (In Perls earlier than 5.8.1 the \fB\-C\fR switch was a Win32\-only switch
395 that enabled the use of Unicode\-aware "wide system call" Win32 APIs.
396 This feature was practically unused, however, and the command line
397 switch was therefore "recycled".)
398 .Sp
399 \&\fBNote:\fR Since perl 5.10.1, if the \fB\-C\fR option is used on the \f(CW\*(C`#!\*(C'\fR line,
400 it must be specified on the command line as well, since the standard streams
401 are already set up at this point in the execution of the perl interpreter.
402 You can also use \fBbinmode()\fR to set the encoding of an I/O stream.
403 .IP \fB\-c\fR 5
404 .IX Xref "-c"
405 .IX Item "-c"
406 causes Perl to check the syntax of the program and then exit without
407 executing it. Actually, it \fIwill\fR execute any \f(CW\*(C`BEGIN\*(C'\fR, \f(CW\*(C`UNITCHECK\*(C'\fR,
408 or \f(CW\*(C`CHECK\*(C'\fR blocks and any \f(CW\*(C`use\*(C'\fR statements: these are considered as
409 occurring outside the execution of your program. \f(CW\*(C`INIT\*(C'\fR and \f(CW\*(C`END\*(C'\fR
410 blocks, however, will be skipped.
411 .Sp
412 If the syntax check is successful perl will exit with a status of zero
413 and report \f(CW\*(C`\fR\f(CIyourprogram\fR\f(CW syntax OK\*(C'\fR. On failure perl will print
414 any detected errors and exit with a non\-zero status.
415 .IP \fB\-d\fR 5
416 .IX Xref "-d -dt"
417 .IX Item "-d"
418 .PD 0
419 .IP \fB\-dt\fR 5
420 .IX Item "-dt"
421 .PD
422 runs the program under the Perl debugger. See perldebug.
423 If \fBt\fR is specified, \f(CW\*(C`PERL5DB_THREADED=1\*(C'\fR is set in the environment
424 to indicate to the debugger that threads will be used in the code
425 being debugged.
426 .IP \fB\-d:\fR\fIMOD[=bar,baz]\fR 5
427 .IX Xref "-d -dt"
428 .IX Item "-d:MOD[=bar,baz]"
429 .PD 0
430 .IP \fB\-dt:\fR\fIMOD[=bar,baz]\fR 5
431 .IX Item "-dt:MOD[=bar,baz]"
432 .PD
433 runs the program under the control of a debugging, profiling, or tracing
434 module installed as \f(CW\*(C`Devel::\fR\f(CIMOD\fR\f(CW\*(C'\fR. E.g., \fB\-d:DProf\fR executes the
435 program using the \f(CW\*(C`Devel::DProf\*(C'\fR profiler. As with the \-M
436 flag, options may be passed to the \f(CW\*(C`Devel::\fR\f(CIMOD\fR\f(CW\*(C'\fR package where they will
437 be received and interpreted by the \f(CW\*(C`Devel::\fR\f(CIMOD\fR\f(CW::import\*(C'\fR routine. Again,
438 like \fB\-M\fR, use \-\fB\-d:\-\fR\f(BIMOD\fR to call \f(CW\*(C`Devel::\fR\f(CIMOD\fR\f(CW::unimport\*(C'\fR instead of
439 import. The comma\-separated list of options must follow a \f(CW\*(C`=\*(C'\fR character.
440 If \fBt\fR is specified, it indicates to the debugger that threads will be used
441 in the code being debugged. See perldebug.
442 .IP \fB\-D\fR\fIletters\fR 5
443 .IX Xref "-D DEBUGGING -DDEBUGGING"
444 .IX Item "-Dletters"
445 .PD 0
446 .IP \fB\-D\fR\fInumber\fR 5
447 .IX Item "-Dnumber"
448 .PD
449 sets debugging flags. This switch is enabled only if your perl binary has
450 been built with debugging enabled: normal production perls won\*(Aqt have
451 been.
452 .Sp
453 For example, to watch how perl executes your program, use \fB\-Dtls\fR.
454 Another nice value is \fB\-Dx\fR, which lists your compiled syntax tree, and
455 \&\fB\-Dr\fR displays compiled regular expressions; the format of the output is
456 explained in perldebguts.
457 .Sp
458 As an alternative, specify a number instead of list of letters (e.g.,
459 \&\fB\-D14\fR is equivalent to \fB\-Dtls\fR):
460 .Sp
461 .Vb 10
462 \& 1 p Tokenizing and parsing (with v, displays parse
463 \& stack)
464 \& 2 s Stack snapshots (with v, displays all stacks)
465 \& 4 l Context (loop) stack processing
466 \& 8 t Trace execution
467 \& 16 o Method and overloading resolution
468 \& 32 c String/numeric conversions
469 \& 64 P Print profiling info, source file input state
470 \& 128 m Memory and SV allocation
471 \& 256 f Format processing
472 \& 512 r Regular expression parsing and execution
473 \& 1024 x Syntax tree dump
474 \& 2048 u Tainting checks
475 \& 4096 U Unofficial, User hacking (reserved for private,
476 \& unreleased use)
477 \& 8192 h Show hash randomization debug output (changes to
478 \& PL_hash_rand_bits and their origin)
479 \& 16384 X Scratchpad allocation
480 \& 32768 D Cleaning up
481 \& 65536 S Op slab allocation
482 \& 131072 T Tokenizing
483 \& 262144 R Include reference counts of dumped variables
484 \& (eg when using \-Ds)
485 \& 524288 J show s,t,P\-debug (don\*(Aqt Jump over) on opcodes within
486 \& package DB
487 \& 1048576 v Verbose: use in conjunction with other flags to
488 \& increase the verbosity of the output. Is a no\-op on
489 \& many of the other flags
490 \& 2097152 C Copy On Write
491 \& 4194304 A Consistency checks on internal structures
492 \& 8388608 q quiet \- currently only suppresses the "EXECUTING"
493 \& message
494 \& 16777216 M trace smart match resolution
495 \& 33554432 B dump suBroutine definitions, including special
496 \& Blocks like BEGIN
497 \& 67108864 L trace Locale\-related info; what gets output is very
498 \& subject to change
499 \& 134217728 i trace PerlIO layer processing. Set PERLIO_DEBUG to
500 \& the filename to trace to.
501 \& 268435456 y trace y///, tr/// compilation and execution
502 .Ve
503 .Sp
504 All these flags require \fB\-DDEBUGGING\fR when you compile the Perl
505 executable (but see \f(CW\*(C`:opd\*(C'\fR in Devel::Peek or "\*(Aqdebug\*(Aq mode" in re
506 which may change this).
507 See the \fIINSTALL\fR file in the Perl source distribution
508 for how to do this.
509 .Sp
510 If you\*(Aqre just trying to get a print out of each line of Perl code
511 as it executes, the way that \f(CW\*(C`sh \-x\*(C'\fR provides for shell scripts,
512 you can\*(Aqt use Perl\*(Aqs \fB\-D\fR switch. Instead do this
513 .Sp
514 .Vb 2
515 \& # If you have "env" utility
516 \& env PERLDB_OPTS="NonStop=1 AutoTrace=1 frame=2" perl \-dS program
517 \&
518 \& # Bourne shell syntax
519 \& $ PERLDB_OPTS="NonStop=1 AutoTrace=1 frame=2" perl \-dS program
520 \&
521 \& # csh syntax
522 \& % (setenv PERLDB_OPTS "NonStop=1 AutoTrace=1 frame=2"; perl \-dS program)
523 .Ve
524 .Sp
525 See perldebug for details and variations.
526 .IP "\fB\-e\fR \fIcommandline\fR" 5
527 .IX Xref "-e"
528 .IX Item "-e commandline"
529 may be used to enter one line of program. If \fB\-e\fR is given, Perl
530 will not look for a filename in the argument list. Multiple \fB\-e\fR
531 commands may be given to build up a multi\-line script. Make sure
532 to use semicolons where you would in a normal program.
533 .IP "\fB\-E\fR \fIcommandline\fR" 5
534 .IX Xref "-E"
535 .IX Item "-E commandline"
536 behaves just like \-e, except that it implicitly
537 enables all optional features and builtin functions (in the main
538 compilation unit). See feature and builtin.
539 .IP \fB\-f\fR 5
540 .IX Xref "-f sitecustomize sitecustomize.pl"
541 .IX Item "-f"
542 Disable executing \fR\f(CI$Config\fR\fI{sitelib}/sitecustomize.pl\fR at startup.
543 .Sp
544 Perl can be built so that it by default will try to execute
545 \&\fR\f(CI$Config\fR\fI{sitelib}/sitecustomize.pl\fR at startup (in a BEGIN block).
546 This is a hook that allows the sysadmin to customize how Perl behaves.
547 It can for instance be used to add entries to the \f(CW@INC\fR array to make Perl
548 find modules in non\-standard locations.
549 .Sp
550 Perl actually inserts the following code:
551 .Sp
552 .Vb 4
553 \& BEGIN {
554 \& do { local $!; \-f "$Config{sitelib}/sitecustomize.pl"; }
555 \& && do "$Config{sitelib}/sitecustomize.pl";
556 \& }
557 .Ve
558 .Sp
559 Since it is an actual \f(CW\*(C`do\*(C'\fR (not a \f(CW\*(C`require\*(C'\fR), \fIsitecustomize.pl\fR
560 doesn\*(Aqt need to return a true value. The code is run in package \f(CW\*(C`main\*(C'\fR,
561 in its own lexical scope. However, if the script dies, \f(CW$@\fR will not
562 be set.
563 .Sp
564 The value of \f(CW$Config{sitelib}\fR is also determined in C code and not
565 read from \f(CW\*(C`Config.pm\*(C'\fR, which is not loaded.
566 .Sp
567 The code is executed \fIvery\fR early. For example, any changes made to
568 \&\f(CW@INC\fR will show up in the output of \`perl \-V\`. Of course, \f(CW\*(C`END\*(C'\fR
569 blocks will be likewise executed very late.
570 .Sp
571 To determine at runtime if this capability has been compiled in your
572 perl, you can check the value of \f(CW$Config{usesitecustomize}\fR.
573 .IP \fB\-F\fR\fIpattern\fR 5
574 .IX Xref "-F"
575 .IX Item "-Fpattern"
576 specifies the pattern to split on for "\-a". The pattern may be
577 surrounded by \f(CW\*(C`//\*(C'\fR, \f(CW""\fR, or \f(CW\*(Aq\*(Aq\fR, otherwise it will be put in single
578 quotes. You can\*(Aqt use literal whitespace or NUL characters in the pattern.
579 .Sp
580 \&\fB\-F\fR implicitly sets both "\-a" and "\-n".
581 .IP \fB\-g\fR 5
582 .IX Xref "-g"
583 .IX Item "-g"
584 undefines the input record separator (\f(CW$/\fR) and thus
585 enables the slurp mode. In other words, it causes Perl to read whole
586 files at once, instead of line by line.
587 .Sp
588 This flag is a simpler alias for \-0777.
589 .Sp
590 Mnemonics: gobble, grab, gulp.
591 .IP \fB\-h\fR 5
592 .IX Xref "-h"
593 .IX Item "-h"
594 prints a summary of the options.
595 .IP \fB\-?\fR 5
596 .IX Xref "-?"
597 .IX Item "-?"
598 synonym for \fB\-h\fR: prints a summary of the options.
599 .IP \fB\-i\fR[\fIextension\fR] 5
600 .IX Xref "-i in-place"
601 .IX Item "-i[extension]"
602 specifies that files processed by the \f(CW\*(C`<>\*(C'\fR construct are to be
603 edited in\-place. It does this by renaming the input file, opening the
604 output file by the original name, and selecting that output file as the
605 default for \fBprint()\fR statements. The extension, if supplied, is used to
606 modify the name of the old file to make a backup copy, following these
607 rules:
608 .Sp
609 If no extension is supplied, and your system supports it, the original
610 \&\fIfile\fR is kept open without a name while the output is redirected to
611 a new file with the original \fIfilename\fR. When perl exits, cleanly or not,
612 the original \fIfile\fR is unlinked.
613 .Sp
614 If the extension doesn\*(Aqt contain a \f(CW\*(C`*\*(C'\fR, then it is appended to the
615 end of the current filename as a suffix. If the extension does
616 contain one or more \f(CW\*(C`*\*(C'\fR characters, then each \f(CW\*(C`*\*(C'\fR is replaced
617 with the current filename. In Perl terms, you could think of this
618 as:
619 .Sp
620 .Vb 1
621 \& ($backup = $extension) =~ s/\e*/$file_name/g;
622 .Ve
623 .Sp
624 This allows you to add a prefix to the backup file, instead of (or in
625 addition to) a suffix:
626 .Sp
627 .Vb 2
628 \& $ perl \-pi\*(Aqorig_*\*(Aq \-e \*(Aqs/bar/baz/\*(Aq fileA # backup to
629 \& # \*(Aqorig_fileA\*(Aq
630 .Ve
631 .Sp
632 Or even to place backup copies of the original files into another
633 directory (provided the directory already exists):
634 .Sp
635 .Vb 2
636 \& $ perl \-pi\*(Aqold/*.orig\*(Aq \-e \*(Aqs/bar/baz/\*(Aq fileA # backup to
637 \& # \*(Aqold/fileA.orig\*(Aq
638 .Ve
639 .Sp
640 These sets of one\-liners are equivalent:
641 .Sp
642 .Vb 2
643 \& $ perl \-pi \-e \*(Aqs/bar/baz/\*(Aq fileA # overwrite current file
644 \& $ perl \-pi\*(Aq*\*(Aq \-e \*(Aqs/bar/baz/\*(Aq fileA # overwrite current file
645 \&
646 \& $ perl \-pi\*(Aq.orig\*(Aq \-e \*(Aqs/bar/baz/\*(Aq fileA # backup to \*(AqfileA.orig\*(Aq
647 \& $ perl \-pi\*(Aq*.orig\*(Aq \-e \*(Aqs/bar/baz/\*(Aq fileA # backup to \*(AqfileA.orig\*(Aq
648 .Ve
649 .Sp
650 From the shell, saying
651 .Sp
652 .Vb 1
653 \& $ perl \-p \-i.orig \-e "s/foo/bar/; ... "
654 .Ve
655 .Sp
656 is the same as using the program:
657 .Sp
658 .Vb 2
659 \& #!/usr/bin/perl \-pi.orig
660 \& s/foo/bar/;
661 .Ve
662 .Sp
663 which is equivalent to
664 .Sp
665 .Vb 10
666 \& #!/usr/bin/perl
667 \& $extension = \*(Aq.orig\*(Aq;
668 \& LINE: while (<>) {
669 \& if ($ARGV ne $oldargv) {
670 \& if ($extension !~ /\e*/) {
671 \& $backup = $ARGV . $extension;
672 \& }
673 \& else {
674 \& ($backup = $extension) =~ s/\e*/$ARGV/g;
675 \& }
676 \& rename($ARGV, $backup);
677 \& open(ARGVOUT, ">$ARGV");
678 \& select(ARGVOUT);
679 \& $oldargv = $ARGV;
680 \& }
681 \& s/foo/bar/;
682 \& }
683 \& continue {
684 \& print; # this prints to original filename
685 \& }
686 \& select(STDOUT);
687 .Ve
688 .Sp
689 except that the \fB\-i\fR form doesn\*(Aqt need to compare \f(CW$ARGV\fR to \f(CW$oldargv\fR to
690 know when the filename has changed. It does, however, use ARGVOUT for
691 the selected filehandle. Note that STDOUT is restored as the default
692 output filehandle after the loop.
693 .Sp
694 As shown above, Perl creates the backup file whether or not any output
695 is actually changed. So this is just a fancy way to copy files:
696 .Sp
697 .Vb 3
698 \& $ perl \-p \-i\*(Aq/some/file/path/*\*(Aq \-e 1 file1 file2 file3...
699 \&or
700 \& $ perl \-p \-i\*(Aq.orig\*(Aq \-e 1 file1 file2 file3...
701 .Ve
702 .Sp
703 You can use \f(CW\*(C`eof\*(C'\fR without parentheses to locate the end of each input
704 file, in case you want to append to each file, or reset line numbering
705 (see example in "eof" in perlfunc).
706 .Sp
707 If, for a given file, Perl is unable to create the backup file as
708 specified in the extension then it will skip that file and continue on
709 with the next one (if it exists).
710 .Sp
711 For a discussion of issues surrounding file permissions and \fB\-i\fR, see
712 "Why does Perl let me delete read\-only files? Why does \-i clobber
713 protected files? Isn\*(Aqt this a bug in Perl?" in perlfaq5.
714 .Sp
715 You cannot use \fB\-i\fR to create directories or to strip extensions from
716 files.
717 .Sp
718 Perl does not expand \f(CW\*(C`~\*(C'\fR in filenames, which is good, since some
719 folks use it for their backup files:
720 .Sp
721 .Vb 1
722 \& $ perl \-pi~ \-e \*(Aqs/foo/bar/\*(Aq file1 file2 file3...
723 .Ve
724 .Sp
725 Note that because \fB\-i\fR renames or deletes the original file before
726 creating a new file of the same name, Unix\-style soft and hard links will
727 not be preserved.
728 .Sp
729 Finally, the \fB\-i\fR switch does not impede execution when no
730 files are given on the command line. In this case, no backup is made
731 (the original file cannot, of course, be determined) and processing
732 proceeds from STDIN to STDOUT as might be expected.
733 .IP \fB\-I\fR\fIdirectory\fR 5
734 .IX Xref "-I @INC"
735 .IX Item "-Idirectory"
736 Directories specified by \fB\-I\fR are prepended to the search path for
737 modules (\f(CW@INC\fR).
738 .IP \fB\-l\fR[\fIoctnum\fR] 5
739 .IX Xref "-l $ $\\"
740 .IX Item "-l[octnum]"
741 enables automatic line\-ending processing. It has two separate
742 effects. First, it automatically chomps \f(CW$/\fR (the input record
743 separator) when used with "\-n" or "\-p". Second, it assigns \f(CW\*(C`$\e\*(C'\fR
744 (the output record separator) to have the value of \fIoctnum\fR so
745 that any print statements will have that separator added back on.
746 If \fIoctnum\fR is omitted, sets \f(CW\*(C`$\e\*(C'\fR to the current value of
747 \&\f(CW$/\fR. For instance, to trim lines to 80 columns:
748 .Sp
749 .Vb 1
750 \& perl \-lpe \*(Aqsubstr($_, 80) = ""\*(Aq
751 .Ve
752 .Sp
753 Note that the assignment \f(CW\*(C`$\e = $/\*(C'\fR is done when the switch is processed,
754 so the input record separator can be different than the output record
755 separator if the \fB\-l\fR switch is followed by a
756 \&\-0 switch:
757 .Sp
758 .Vb 1
759 \& gnufind / \-print0 | perl \-ln0e \*(Aqprint "found $_" if \-p\*(Aq
760 .Ve
761 .Sp
762 This sets \f(CW\*(C`$\e\*(C'\fR to newline and then sets \f(CW$/\fR to the null character.
763 .IP \fB\-m\fR[\fB\-\fR]\fImodule\fR 5
764 .IX Xref "-m -M"
765 .IX Item "-m[-]module"
766 .PD 0
767 .IP \fB\-M\fR[\fB\-\fR]\fImodule\fR 5
768 .IX Item "-M[-]module"
769 .IP "\fB\-M\fR[\fB\-\fR]\fI\*(Aqmodule ...\*(Aq\fR" 5
770 .IX Item "-M[-]'module ...'"
771 .IP \fB\-[mM]\fR[\fB\-\fR]\fImodule=arg[,arg]...\fR 5
772 .IX Item "-[mM][-]module=arg[,arg]..."
773 .PD
774 \&\fB\-m\fR\fImodule\fR executes \f(CW\*(C`use\ \fR\f(CImodule\fR\f(CW\ ();\*(C'\fR before executing your
775 program. This loads the module, but does not call its \f(CW\*(C`import\*(C'\fR method,
776 so does not import subroutines and does not give effect to a pragma.
777 .Sp
778 \&\fB\-M\fR\fImodule\fR executes \f(CW\*(C`use\ \fR\f(CImodule\fR\f(CW;\*(C'\fR before executing your
779 program. This loads the module and calls its \f(CW\*(C`import\*(C'\fR method, causing
780 the module to have its default effect, typically importing subroutines
781 or giving effect to a pragma.
782 You can use quotes to add extra code after the module name,
783 e.g., \f(CW\*(Aq\-M\fR\f(CIMODULE\fR\f(CW qw(foo bar)\*(Aq\fR.
784 .Sp
785 If the first character after the \fB\-M\fR or \fB\-m\fR is a dash (\fB\-\fR)
786 then the \*(Aquse\*(Aq is replaced with \*(Aqno\*(Aq.
787 This makes no difference for \fB\-m\fR.
788 .Sp
789 Since Perl version 5.39.8, the \f(CW\*(C`\-M\*(C'\fR switch and the module name can now
790 be passed in separate command\-line arguments:
791 .Sp
792 .Vb 2
793 \& perl \-M MODULE ... # like perl \-MMODULE ...
794 \& perl \-M MODULE=arg1,arg2,... # like perl \-MMODULE=arg1,arg2,...
795 .Ve
796 .Sp
797 A little builtin syntactic sugar means you can also say
798 \&\fB\-m\fR\f(BIMODULE\fR\fB=foo,bar\fR or \fB\-M\fR\f(BIMODULE\fR\fB=foo,bar\fR as a shortcut for
799 \&\fB\*(Aq\-M\fR\f(BIMODULE\fR\fB qw(foo bar)\*(Aq\fR. This avoids the need to use quotes when
800 importing symbols. The actual code generated by \fB\-M\fR\f(BIMODULE\fR\fB=foo,bar\fR is
801 \&\f(CW\*(C`use module split(/,/,q{foo,bar})\*(C'\fR. Note that the \f(CW\*(C`=\*(C'\fR form
802 removes the distinction between \fB\-m\fR and \fB\-M\fR; that is,
803 \&\fB\-m\fR\f(BIMODULE\fR\fB=foo,bar\fR is the same as \fB\-M\fR\f(BIMODULE\fR\fB=foo,bar\fR.
804 .Sp
805 A consequence of the \f(CW\*(C`split\*(C'\fR formulation
806 is that \fB\-M\fR\f(BIMODULE\fR\fB=number\fR never does a version check,
807 unless \f(CW\*(C`\fR\f(CIMODULE\fR\f(CW::import()\*(C'\fR itself is set up to do a version check, which
808 could happen for example if \fIMODULE\fR inherits from Exporter.
809 .IP \fB\-n\fR 5
810 .IX Xref "-n"
811 .IX Item "-n"
812 causes Perl to assume the following loop around your program, which
813 makes it iterate over filename arguments somewhat like \fIsed \-n\fR or
814 \&\fIawk\fR:
815 .Sp
816 .Vb 4
817 \& LINE:
818 \& while (<>) {
819 \& ... # your program goes here
820 \& }
821 .Ve
822 .Sp
823 Note that the lines are not printed by default. See "\-p" to have
824 lines printed. If a file named by an argument cannot be opened for
825 some reason, Perl warns you about it and moves on to the next file.
826 .Sp
827 Also note that \f(CW\*(C`<>\*(C'\fR passes command line arguments to
828 "open" in perlfunc, which doesn\*(Aqt necessarily interpret them as file names.
829 See perlop for possible security implications.
830 .Sp
831 Here is an efficient way to delete all files that haven\*(Aqt been modified for
832 at least a week:
833 .Sp
834 .Vb 1
835 \& find . \-mtime +7 \-print | perl \-nle unlink
836 .Ve
837 .Sp
838 This is faster than using the \fB\-exec\fR switch of \fIfind\fR because you don\*(Aqt
839 have to start a process on every filename found (but it\*(Aqs not faster
840 than using the \fB\-delete\fR switch available in newer versions of \fIfind\fR.
841 It does suffer from the bug of mishandling newlines in pathnames, which
842 you can fix if you follow the example under
843 \&\-0.
844 .Sp
845 \&\f(CW\*(C`BEGIN\*(C'\fR and \f(CW\*(C`END\*(C'\fR blocks may be used to capture control before or after
846 the implicit program loop, just as in \fIawk\fR.
847 .IP \fB\-p\fR 5
848 .IX Xref "-p"
849 .IX Item "-p"
850 causes Perl to assume the following loop around your program, which
851 makes it iterate over filename arguments somewhat like \fIsed\fR:
852 .Sp
853 .Vb 6
854 \& LINE:
855 \& while (<>) {
856 \& ... # your program goes here
857 \& } continue {
858 \& print or die "\-p destination: $!\en";
859 \& }
860 .Ve
861 .Sp
862 If a file named by an argument cannot be opened for some reason, Perl
863 warns you about it, and moves on to the next file. Note that the
864 lines are printed automatically. An error occurring during printing is
865 treated as fatal. To suppress printing use the "\-n" switch. A \fB\-p\fR
866 overrides a \fB\-n\fR switch.
867 .Sp
868 \&\f(CW\*(C`BEGIN\*(C'\fR and \f(CW\*(C`END\*(C'\fR blocks may be used to capture control before or after
869 the implicit loop, just as in \fIawk\fR.
870 .IP \fB\-s\fR 5
871 .IX Xref "-s"
872 .IX Item "-s"
873 enables rudimentary switch parsing for switches on the command
874 line after the program name but before any filename arguments (or before
875 an argument of \fB\-\-\fR). Any switch found there is removed from \f(CW@ARGV\fR and sets the
876 corresponding variable in the Perl program, in the main package. The following program
877 prints "1" if the program is invoked with a \fB\-xyz\fR switch, and "abc"
878 if it is invoked with \fB\-xyz=abc\fR.
879 .Sp
880 .Vb 2
881 \& #!/usr/bin/perl \-s
882 \& if ($xyz) { print "$xyz\en" }
883 .Ve
884 .Sp
885 Do note that a switch like \fB\-\-help\fR creates the variable \f(CW\*(C`${\-help}\*(C'\fR, which is
886 not compliant with \f(CW\*(C`use strict "refs"\*(C'\fR. Also, when using this option on a
887 script with warnings enabled you may get a lot of spurious "used only once"
888 warnings. For these reasons, use of \fB\-s\fR is discouraged. See Getopt::Long
889 for much more flexible switch parsing.
890 .IP \fB\-S\fR 5
891 .IX Xref "-S"
892 .IX Item "-S"
893 makes Perl use the "PATH" environment variable to search for the
894 program unless the name of the program contains path separators.
895 .Sp
896 On some platforms, this also makes Perl append suffixes to the
897 filename while searching for it. For example, on Win32 platforms,
898 the ".bat" and ".cmd" suffixes are appended if a lookup for the
899 original name fails, and if the name does not already end in one
900 of those suffixes. If your Perl was compiled with \f(CW\*(C`DEBUGGING\*(C'\fR turned
901 on, using the \-Dp switch to Perl shows how the search
902 progresses.
903 .Sp
904 Typically this is used to emulate \f(CW\*(C`#!\*(C'\fR startup on platforms that don\*(Aqt
905 support \f(CW\*(C`#!\*(C'\fR. It\*(Aqs also convenient when debugging a script that uses \f(CW\*(C`#!\*(C'\fR,
906 and is thus normally found by the shell\*(Aqs \f(CW$PATH\fR search mechanism.
907 .Sp
908 This example works on many platforms that have a shell compatible with
909 Bourne shell:
910 .Sp
911 .Vb 3
912 \& #!/usr/bin/perl
913 \& eval \*(Aqexec /usr/bin/perl \-wS $0 ${1+"$@"}\*(Aq
914 \& if 0; # ^ Run only under a shell
915 .Ve
916 .Sp
917 The system ignores the first line and feeds the program to \fI/bin/sh\fR,
918 which proceeds to try to execute the Perl program as a shell script.
919 The shell executes the second line as a normal shell command, and thus
920 starts up the Perl interpreter. On some systems \f(CW$0\fR doesn\*(Aqt always
921 contain the full pathname, so the "\-S" tells Perl to search for the
922 program if necessary. After Perl locates the program, it parses the
923 lines and ignores them because the check \*(Aqif 0\*(Aq is never true.
924 If the program will be interpreted by csh, you will need
925 to replace \f(CW\*(C`${1+"$@"}\*(C'\fR with \f(CW$*\fR, even though that doesn\*(Aqt understand
926 embedded spaces (and such) in the argument list. To start up \fIsh\fR rather
927 than \fIcsh\fR, some systems may have to replace the \f(CW\*(C`#!\*(C'\fR line with a line
928 containing just a colon, which will be politely ignored by Perl. Other
929 systems can\*(Aqt control that, and need a totally devious construct that
930 will work under any of \fIcsh\fR, \fIsh\fR, or Perl, such as the following:
931 .Sp
932 .Vb 3
933 \& eval \*(Aq(exit $?0)\*(Aq && eval \*(Aqexec perl \-wS $0 ${1+"$@"}\*(Aq
934 \& & eval \*(Aqexec /usr/bin/perl \-wS $0 $argv:q\*(Aq
935 \& if 0; # ^ Run only under a shell
936 .Ve
937 .Sp
938 If the filename supplied contains directory separators (and so is an
939 absolute or relative pathname), and if that file is not found,
940 platforms that append file extensions will do so and try to look
941 for the file with those extensions added, one by one.
942 .Sp
943 On DOS\-like platforms, if the program does not contain directory
944 separators, it will first be searched for in the current directory
945 before being searched for on the PATH. On Unix platforms, the
946 program will be searched for strictly on the PATH.
947 .IP \fB\-t\fR 5
948 .IX Xref "-t"
949 .IX Item "-t"
950 Like "\-T", but taint checks will issue warnings rather than fatal
951 errors. These warnings can now be controlled normally with \f(CWno warnings
952 qw(taint)\fR.
953 .Sp
954 \&\fBNote: This is not a substitute for \fR\f(CB\*(C`\-T\*(C'\fR\fB!\fR This is meant to be
955 used \fIonly\fR as a temporary development aid while securing legacy code:
956 for real production code and for new secure code written from scratch,
957 always use the real "\-T".
958 .Sp
959 This has no effect if your perl was built without taint support.
960 .IP \fB\-T\fR 5
961 .IX Xref "-T"
962 .IX Item "-T"
963 turns on "taint" so you can test them. Ordinarily
964 these checks are done only when running setuid or setgid. It\*(Aqs a
965 good idea to turn them on explicitly for programs that run on behalf
966 of someone else whom you might not necessarily trust, such as CGI
967 programs or any internet servers you might write in Perl. See
968 perlsec for details. For security reasons, this option must be
969 seen by Perl quite early; usually this means it must appear early
970 on the command line or in the \f(CW\*(C`#!\*(C'\fR line for systems which support
971 that construct.
972 .IP \fB\-u\fR 5
973 .IX Xref "-u"
974 .IX Item "-u"
975 This switch causes Perl to dump core after compiling your
976 program. You can then in theory take this core dump and turn it
977 into an executable file by using the \fIundump\fR program (not supplied).
978 This speeds startup at the expense of some disk space (which you
979 can minimize by stripping the executable). (Still, a "hello world"
980 executable comes out to about 200K on my machine.) If you want to
981 execute a portion of your program before dumping, use the \f(CWCORE::dump()\fR
982 function instead. Note: availability of \fIundump\fR is platform
983 specific and may not be available for a specific port of Perl.
984 .IP \fB\-U\fR 5
985 .IX Xref "-U"
986 .IX Item "-U"
987 allows Perl to do unsafe operations. Currently the only "unsafe"
988 operations are attempting to unlink directories while running as superuser
989 and running setuid programs with fatal taint checks turned into warnings.
990 Note that warnings must be enabled along with this option to actually
991 \&\fIgenerate\fR the taint\-check warnings.
992 .IP \fB\-v\fR 5
993 .IX Xref "-v"
994 .IX Item "-v"
995 prints the version and patchlevel of your perl executable.
996 .IP \fB\-V\fR 5
997 .IX Xref "-V"
998 .IX Item "-V"
999 prints summary of the major perl configuration values and the current
1000 values of \f(CW@INC\fR.
1001 .IP \fB\-V:\fR\fIconfigvar\fR 5
1002 .IX Item "-V:configvar"
1003 Prints to STDOUT the value of the named configuration variable(s),
1004 with multiples when your \f(CW\*(C`\fR\f(CIconfigvar\fR\f(CW\*(C'\fR argument looks like a regex (has
1005 non\-letters). For example:
1006 .Sp
1007 .Vb 12
1008 \& $ perl \-V:libc
1009 \& libc=\*(Aq/lib/libc\-2.2.4.so\*(Aq;
1010 \& $ perl \-V:lib.
1011 \& libs=\*(Aq\-lnsl \-lgdbm \-ldb \-ldl \-lm \-lcrypt \-lutil \-lc\*(Aq;
1012 \& libc=\*(Aq/lib/libc\-2.2.4.so\*(Aq;
1013 \& $ perl \-V:lib.*
1014 \& libpth=\*(Aq/usr/local/lib /lib /usr/lib\*(Aq;
1015 \& libs=\*(Aq\-lnsl \-lgdbm \-ldb \-ldl \-lm \-lcrypt \-lutil \-lc\*(Aq;
1016 \& lib_ext=\*(Aq.a\*(Aq;
1017 \& libc=\*(Aq/lib/libc\-2.2.4.so\*(Aq;
1018 \& libperl=\*(Aqlibperl.a\*(Aq;
1019 \& ....
1020 .Ve
1021 .Sp
1022 Additionally, extra colons can be used to control formatting. A
1023 trailing colon suppresses the linefeed and terminator ";", allowing
1024 you to embed queries into shell commands. (mnemonic: PATH separator
1025 ":".)
1026 .Sp
1027 .Vb 2
1028 \& $ echo "compression\-vars: " \`perl \-V:z.*: \` " are here !"
1029 \& compression\-vars: zcat=\*(Aq\*(Aq zip=\*(Aqzip\*(Aq are here !
1030 .Ve
1031 .Sp
1032 A leading colon removes the "name=" part of the response, this allows
1033 you to map to the name you need. (mnemonic: empty label)
1034 .Sp
1035 .Vb 2
1036 \& $ echo "goodvfork="\`./perl \-Ilib \-V::usevfork\`
1037 \& goodvfork=false;
1038 .Ve
1039 .Sp
1040 Leading and trailing colons can be used together if you need
1041 positional parameter values without the names. Note that in the case
1042 below, the \f(CW\*(C`PERL_API\*(C'\fR params are returned in alphabetical order.
1043 .Sp
1044 .Vb 2
1045 \& $ echo building_on \`perl \-V::osname: \-V::PERL_API_.*:\` now
1046 \& building_on \*(Aqlinux\*(Aq \*(Aq5\*(Aq \*(Aq1\*(Aq \*(Aq9\*(Aq now
1047 .Ve
1048 .IP \fB\-w\fR 5
1049 .IX Xref "-w"
1050 .IX Item "-w"
1051 prints warnings about dubious constructs, such as variable names
1052 mentioned only once and scalar variables used
1053 before being set; redefined subroutines; references to undefined
1054 filehandles; filehandles opened read\-only that you are attempting
1055 to write on; values used as a number that don\*(Aqt \fIlook\fR like numbers;
1056 using an array as though it were a scalar; if your subroutines
1057 recurse more than 100 deep; and innumerable other things.
1058 .Sp
1059 This switch really just enables the global \f(CW$^W\fR variable; normally,
1060 the lexically scoped \f(CW\*(C`use warnings\*(C'\fR pragma is preferred. You
1061 can disable or promote into fatal errors specific warnings using
1062 \&\f(CW\*(C`_\|_WARN_\|_\*(C'\fR hooks, as described in perlvar and "warn" in perlfunc.
1063 See also perldiag and perltrap. A fine\-grained warning
1064 facility is also available if you want to manipulate entire classes
1065 of warnings; see warnings.
1066 .IP \fB\-W\fR 5
1067 .IX Xref "-W"
1068 .IX Item "-W"
1069 Enables all warnings regardless of \f(CW\*(C`no warnings\*(C'\fR or \f(CW$^W\fR.
1070 See warnings.
1071 .IP \fB\-X\fR 5
1072 .IX Xref "-X"
1073 .IX Item "-X"
1074 Disables all warnings regardless of \f(CW\*(C`use warnings\*(C'\fR or \f(CW$^W\fR.
1075 See warnings.
1076 .Sp
1077 Forbidden in \f(CW"PERL5OPT"\fR.
1078 .IP \fB\-x\fR 5
1079 .IX Xref "-x"
1080 .IX Item "-x"
1081 .PD 0
1082 .IP \fB\-x\fR\fIdirectory\fR 5
1083 .IX Item "-xdirectory"
1084 .PD
1085 tells Perl that the program is embedded in a larger chunk of unrelated
1086 text, such as in a mail message. Leading garbage will be
1087 discarded until the first line that starts with \f(CW\*(C`#!\*(C'\fR and contains the
1088 string "perl". Any meaningful switches on that line will be applied.
1089 .Sp
1090 All references to line numbers by the program (warnings, errors, ...)
1091 will treat the \f(CW\*(C`#!\*(C'\fR line as the first line.
1092 Thus a warning on the 2nd line of the program, which is on the 100th
1093 line in the file will be reported as line 2, not as line 100.
1094 This can be overridden by using the \f(CW\*(C`#line\*(C'\fR directive.
1095 (See "Plain Old Comments (Not!)" in perlsyn)
1096 .Sp
1097 If a directory name is specified, Perl will switch to that directory
1098 before running the program. The \fB\-x\fR switch controls only the
1099 disposal of leading garbage. The program must be terminated with
1100 \&\f(CW\*(C`_\|_END_\|_\*(C'\fR if there is trailing garbage to be ignored; the program
1101 can process any or all of the trailing garbage via the \f(CW\*(C`DATA\*(C'\fR filehandle
1102 if desired.
1103 .Sp
1104 The directory, if specified, must appear immediately following the \fB\-x\fR
1105 with no intervening whitespace.
1106 .SH ENVIRONMENT
1107 .IX Xref "perl, environment variables"
1108 .IX Header "ENVIRONMENT"
1109 .IP HOME 12
1110 .IX Xref "HOME"
1111 .IX Item "HOME"
1112 Used if \f(CW\*(C`chdir\*(C'\fR has no argument.
1113 .IP LOGDIR 12
1114 .IX Xref "LOGDIR"
1115 .IX Item "LOGDIR"
1116 Used if \f(CW\*(C`chdir\*(C'\fR has no argument and "HOME" is not set.
1117 .IP PATH 12
1118 .IX Xref "PATH"
1119 .IX Item "PATH"
1120 Used in executing subprocesses, and in finding the program if "\-S" is
1121 used.
1122 .IP PERL5LIB 12
1123 .IX Xref "PERL5LIB"
1124 .IX Item "PERL5LIB"
1125 A list of directories in which to look for Perl library files before
1126 looking in the standard library.
1127 Any architecture\-specific and version\-specific directories,
1128 such as \fIversion/archname/\fR, \fIversion/\fR, or \fIarchname/\fR under the
1129 specified locations are automatically included if they exist, with this
1130 lookup done at interpreter startup time. In addition, any directories
1131 matching the entries in \f(CW$Config{inc_version_list}\fR are added.
1132 (These typically would be for older compatible perl versions installed
1133 in the same directory tree.)
1134 .Sp
1135 If PERL5LIB is not defined, "PERLLIB" is used. Directories are separated
1136 (like in PATH) by a colon on Unixish platforms and by a semicolon on
1137 Windows (the proper path separator being given by the command \f(CW\*(C`perl
1138 \&\-V:\fR\f(CIpath_sep\fR\f(CW\*(C'\fR).
1139 .Sp
1140 When running taint checks, either because the program was running setuid or
1141 setgid, or the "\-T" or "\-t" switch was specified, neither PERL5LIB nor
1142 "PERLLIB" is consulted. The program should instead say:
1143 .Sp
1144 .Vb 1
1145 \& use lib "/my/directory";
1146 .Ve
1147 .IP PERL5OPT 12
1148 .IX Xref "PERL5OPT"
1149 .IX Item "PERL5OPT"
1150 Command\-line options (switches). Switches in this variable are treated
1151 as if they were on every Perl command line. Only the \fB\-[CDIMTUWdmtw]\fR
1152 switches are allowed. When running taint checks (either because the
1153 program was running setuid or setgid, or because the "\-T" or "\-t"
1154 switch was used), this variable is ignored. If PERL5OPT begins with
1155 \&\fB\-T\fR, tainting will be enabled and subsequent options ignored. If
1156 PERL5OPT begins with \fB\-t\fR, tainting will be enabled, a writable dot
1157 removed from \f(CW@INC\fR, and subsequent options honored.
1158 .IP PERLIO 12
1159 .IX Xref "PERLIO"
1160 .IX Item "PERLIO"
1161 A space (or colon) separated list of PerlIO layers. If perl is built
1162 to use PerlIO system for IO (the default) these layers affect Perl\*(Aqs IO.
1163 .Sp
1164 It is conventional to start layer names with a colon (for example, \f(CW\*(C`:perlio\*(C'\fR) to
1165 emphasize their similarity to variable "attributes". But the code that parses
1166 layer specification strings, which is also used to decode the PERLIO
1167 environment variable, treats the colon as a separator.
1168 .Sp
1169 An unset or empty PERLIO is equivalent to the default set of layers for
1170 your platform; for example, \f(CW\*(C`:unix:perlio\*(C'\fR on Unix\-like systems
1171 and \f(CW\*(C`:unix:crlf\*(C'\fR on Windows and other DOS\-like systems.
1172 .Sp
1173 The list becomes the default for \fIall\fR Perl\*(Aqs IO. Consequently only built\-in
1174 layers can appear in this list, as external layers (such as \f(CW:encoding()\fR) need
1175 IO in order to load them! See "open pragma" for how to add external
1176 encodings as defaults.
1177 .Sp
1178 Layers it makes sense to include in the PERLIO environment
1179 variable are briefly summarized below. For more details see PerlIO.
1180 .RS 12
1181 .IP :crlf 8
1182 .IX Xref ":crlf"
1183 .IX Item ":crlf"
1184 A layer which does CRLF to \f(CW"\en"\fR translation distinguishing "text" and
1185 "binary" files in the manner of MS\-DOS and similar operating systems,
1186 and also provides buffering similar to \f(CW\*(C`:perlio\*(C'\fR on these architectures.
1187 .IP :perlio 8
1188 .IX Xref ":perlio"
1189 .IX Item ":perlio"
1190 This is a re\-implementation of stdio\-like buffering written as a
1191 PerlIO layer. As such it will call whatever layer is below it for
1192 its operations, typically \f(CW\*(C`:unix\*(C'\fR.
1193 .IP :stdio 8
1194 .IX Xref ":stdio"
1195 .IX Item ":stdio"
1196 This layer provides a PerlIO interface by wrapping system\*(Aqs ANSI C "stdio"
1197 library calls. The layer provides both buffering and IO.
1198 Note that the \f(CW\*(C`:stdio\*(C'\fR layer does \fInot\fR do CRLF translation even if that
1199 is the platform\*(Aqs normal behaviour. You will need a \f(CW\*(C`:crlf\*(C'\fR layer above it
1200 to do that.
1201 .IP :unix 8
1202 .IX Xref ":unix"
1203 .IX Item ":unix"
1204 Low\-level layer that calls \f(CW\*(C`read\*(C'\fR, \f(CW\*(C`write\*(C'\fR, \f(CW\*(C`lseek\*(C'\fR, etc.
1205 .RE
1206 .RS 12
1207 .Sp
1208 The default set of layers should give acceptable results on all platforms.
1209 .Sp
1210 For Unix platforms that will be the equivalent of ":unix:perlio" or ":stdio".
1211 Configure is set up to prefer the ":stdio" implementation if the system\*(Aqs library
1212 provides for fast access to the buffer (not common on modern architectures);
1213 otherwise, it uses the ":unix:perlio" implementation.
1214 .Sp
1215 On Win32 the default in this release (5.30) is ":unix:crlf". Win32\*(Aqs ":stdio"
1216 has a number of bugs/mis\-features for Perl IO which are somewhat dependent
1217 on the version and vendor of the C compiler. Using our own \f(CW\*(C`:crlf\*(C'\fR layer as
1218 the buffer avoids those issues and makes things more uniform.
1219 .Sp
1220 This release (5.30) uses \f(CW\*(C`:unix\*(C'\fR as the bottom layer on Win32, and so still
1221 uses the C compiler\*(Aqs numeric file descriptor routines.
1222 .Sp
1223 The PERLIO environment variable is completely ignored when Perl
1224 is run in taint mode.
1225 .RE
1226 .IP PERLIO_DEBUG 12
1227 .IX Xref "PERLIO_DEBUG"
1228 .IX Item "PERLIO_DEBUG"
1229 If set to the name of a file or device when Perl is run with the
1230 \&\-Di command\-line switch, the logging of certain operations
1231 of the PerlIO subsystem will be redirected to the specified file rather
1232 than going to stderr, which is the default. The file is opened in append
1233 mode. Typical uses are in Unix:
1234 .Sp
1235 .Vb 1
1236 \& % env PERLIO_DEBUG=/tmp/perlio.log perl \-Di script ...
1237 .Ve
1238 .Sp
1239 and under Win32, the approximately equivalent:
1240 .Sp
1241 .Vb 2
1242 \& > set PERLIO_DEBUG=CON
1243 \& perl \-Di script ...
1244 .Ve
1245 .Sp
1246 This functionality is disabled for setuid scripts, for scripts run
1247 with "\-T", and for scripts run on a Perl built without \f(CW\*(C`\-DDEBUGGING\*(C'\fR
1248 support.
1249 .IP PERLLIB 12
1250 .IX Xref "PERLLIB"
1251 .IX Item "PERLLIB"
1252 A list of directories in which to look for Perl library
1253 files before looking in the standard library.
1254 If "PERL5LIB" is defined, PERLLIB is not used.
1255 .Sp
1256 The PERLLIB environment variable is completely ignored when Perl
1257 is run in taint mode.
1258 .IP PERL5DB 12
1259 .IX Xref "PERL5DB"
1260 .IX Item "PERL5DB"
1261 The command used to load the debugger code. The default is:
1262 .Sp
1263 .Vb 1
1264 \& BEGIN { require "perl5db.pl" }
1265 .Ve
1266 .Sp
1267 The PERL5DB environment variable is only used when Perl is started with
1268 a bare "\-d" switch.
1269 .IP PERL5DB_THREADED 12
1270 .IX Xref "PERL5DB_THREADED"
1271 .IX Item "PERL5DB_THREADED"
1272 If set to a true value, indicates to the debugger that the code being
1273 debugged uses threads.
1274 .IP "PERL5SHELL (specific to the Win32 port)" 12
1275 .IX Xref "PERL5SHELL"
1276 .IX Item "PERL5SHELL (specific to the Win32 port)"
1277 On Win32 ports only, may be set to an alternative shell that Perl must use
1278 internally for executing "backtick" commands or \fBsystem()\fR. Default is
1279 \&\f(CW\*(C`cmd.exe /x/d/c\*(C'\fR on WindowsNT and \f(CW\*(C`command.com /c\*(C'\fR on Windows95. The
1280 value is considered space\-separated. Precede any character that
1281 needs to be protected, like a space or backslash, with another backslash.
1282 .Sp
1283 Note that Perl doesn\*(Aqt use COMSPEC for this purpose because
1284 COMSPEC has a high degree of variability among users, leading to
1285 portability concerns. Besides, Perl can use a shell that may not be
1286 fit for interactive use, and setting COMSPEC to such a shell may
1287 interfere with the proper functioning of other programs (which usually
1288 look in COMSPEC to find a shell fit for interactive use).
1289 .Sp
1290 Before Perl 5.10.0 and 5.8.8, PERL5SHELL was not taint checked
1291 when running external commands. It is recommended that
1292 you explicitly set (or delete) \f(CW$ENV{PERL5SHELL}\fR when running
1293 in taint mode under Windows.
1294 .IP "PERL_ALLOW_NON_IFS_LSP (specific to the Win32 port)" 12
1295 .IX Xref "PERL_ALLOW_NON_IFS_LSP"
1296 .IX Item "PERL_ALLOW_NON_IFS_LSP (specific to the Win32 port)"
1297 Set to 1 to allow the use of non\-IFS compatible LSPs (Layered Service Providers).
1298 Perl normally searches for an IFS\-compatible LSP because this is required
1299 for its emulation of Windows sockets as real filehandles. However, this may
1300 cause problems if you have a firewall such as \fIMcAfee Guardian\fR, which requires
1301 that all applications use its LSP but which is not IFS\-compatible, because clearly
1302 Perl will normally avoid using such an LSP.
1303 .Sp
1304 Setting this environment variable to 1 means that Perl will simply use the
1305 first suitable LSP enumerated in the catalog, which keeps \fIMcAfee Guardian\fR
1306 happy\-\-and in that particular case Perl still works too because \fIMcAfee
1307 Guardian\fR\*(Aqs LSP actually plays other games which allow applications
1308 requiring IFS compatibility to work.
1309 .IP PERL_DEBUG_MSTATS 12
1310 .IX Xref "PERL_DEBUG_MSTATS"
1311 .IX Item "PERL_DEBUG_MSTATS"
1312 Relevant only if Perl is compiled with the \f(CW\*(C`malloc\*(C'\fR included with the Perl
1313 distribution; that is, if \f(CW\*(C`perl \-V:d_mymalloc\*(C'\fR is "define".
1314 .Sp
1315 If set, this dumps out memory statistics after execution. If set
1316 to an integer greater than one, also dumps out memory statistics
1317 after compilation.
1318 .IP PERL_DESTRUCT_LEVEL 12
1319 .IX Xref "PERL_DESTRUCT_LEVEL"
1320 .IX Item "PERL_DESTRUCT_LEVEL"
1321 Controls the behaviour of global destruction of objects and other
1322 references. See "PERL_DESTRUCT_LEVEL" in perlhacktips for more information.
1323 .IP PERL_DL_NONLAZY 12
1324 .IX Xref "PERL_DL_NONLAZY"
1325 .IX Item "PERL_DL_NONLAZY"
1326 Set to \f(CW"1"\fR to have Perl resolve \fIall\fR undefined symbols when it loads
1327 a dynamic library. The default behaviour is to resolve symbols when
1328 they are used. Setting this variable is useful during testing of
1329 extensions, as it ensures that you get an error on misspelled function
1330 names even if the test suite doesn\*(Aqt call them.
1331 .IP PERL_ENCODING 12
1332 .IX Xref "PERL_ENCODING"
1333 .IX Item "PERL_ENCODING"
1334 If using the \f(CW\*(C`use encoding\*(C'\fR pragma without an explicit encoding name, the
1335 PERL_ENCODING environment variable is consulted for an encoding name.
1336 .IP PERL_HASH_SEED 12
1337 .IX Xref "PERL_HASH_SEED"
1338 .IX Item "PERL_HASH_SEED"
1339 (Since Perl 5.8.1, new semantics in Perl 5.18.0) Used to override
1340 the randomization of Perl\*(Aqs internal hash function. The value is expressed
1341 in hexadecimal, and may include a leading 0x. Truncated patterns
1342 are treated as though they are suffixed with sufficient 0\*(Aqs as required.
1343 .Sp
1344 If the option is provided, and \f(CW\*(C`PERL_PERTURB_KEYS\*(C'\fR is NOT set, then
1345 a value of \*(Aq0\*(Aq implies \f(CW\*(C`PERL_PERTURB_KEYS=0\*(C'\fR/\f(CW\*(C`PERL_PERTURB_KEYS=NO\*(C'\fR
1346 and any other value implies
1347 \&\f(CW\*(C`PERL_PERTURB_KEYS=2\*(C'\fR/\f(CW\*(C`PERL_PERTURB_KEYS=DETERMINISTIC\*(C'\fR. See the
1348 documentation for PERL_PERTURB_KEYS for important
1349 caveats regarding the \f(CW\*(C`DETERMINISTIC\*(C'\fR mode.
1350 .Sp
1351 \&\fBPLEASE NOTE: The hash seed is sensitive information\fR. Hashes are
1352 randomized to protect against local and remote attacks against Perl
1353 code. By manually setting a seed, this protection may be partially or
1354 completely lost.
1355 .Sp
1356 See "Algorithmic Complexity Attacks" in perlsec, "PERL_PERTURB_KEYS", and
1357 "PERL_HASH_SEED_DEBUG" for more information.
1358 .IP PERL_PERTURB_KEYS 12
1359 .IX Xref "PERL_PERTURB_KEYS"
1360 .IX Item "PERL_PERTURB_KEYS"
1361 (Since Perl 5.18.0) Set to \f(CW"0"\fR or \f(CW"NO"\fR then traversing keys
1362 will be repeatable from run to run for the same \f(CW\*(C`PERL_HASH_SEED\*(C'\fR.
1363 Insertion into a hash will not change the order, except to provide
1364 for more space in the hash. When combined with setting PERL_HASH_SEED
1365 this mode is as close to pre 5.18 behavior as you can get.
1366 .Sp
1367 When set to \f(CW"1"\fR or \f(CW"RANDOM"\fR then traversing keys will be randomized.
1368 Every time a hash is inserted into the key order will change in a random
1369 fashion. The order may not be repeatable in a following program run
1370 even if the PERL_HASH_SEED has been specified. This is the default
1371 mode for perl when no PERL_HASH_SEED has been explicitly provided.
1372 .Sp
1373 When set to \f(CW"2"\fR or \f(CW"DETERMINISTIC"\fR then inserting keys into a hash
1374 will cause the key order to change, but in a way that is repeatable from
1375 program run to program run, provided that the same hash seed is used,
1376 and that the code does not itself perform any non\-deterministic
1377 operations and also provided exactly the same environment context.
1378 Adding or removing an environment variable may and likely will change
1379 the key order. If any part of the code builds a hash using non\-
1380 deterministic keys, for instance a hash keyed by the stringified form of
1381 a reference, or the address of the objects it contains, then this may
1382 and likely will have a global effect on the key order of *every* hash in
1383 the process. To work properly this setting MUST be coupled with the
1384 PERL_HASH_SEED to produce deterministic results,
1385 and in fact, if you do set the \f(CW\*(C`PERL_HASH_SEED\*(C'\fR explicitly you do not
1386 need to set this as well, it will be automatically set to this mode.
1387 .Sp
1388 \&\fBNOTE:\fR Use of this option is considered insecure, and is intended only
1389 for debugging non\-deterministic behavior in Perl\*(Aqs hash function. Do
1390 not use it in production.
1391 .Sp
1392 See "Algorithmic Complexity Attacks" in perlsec and "PERL_HASH_SEED"
1393 and "PERL_HASH_SEED_DEBUG" for more information. You can get and set the
1394 key traversal mask for a specific hash by using the \f(CWhash_traversal_mask()\fR
1395 function from Hash::Util.
1396 .IP PERL_HASH_SEED_DEBUG 12
1397 .IX Xref "PERL_HASH_SEED_DEBUG"
1398 .IX Item "PERL_HASH_SEED_DEBUG"
1399 (Since Perl 5.8.1.) Set to \f(CW"1"\fR to display (to STDERR) information
1400 about the hash function, seed, and what type of key traversal
1401 randomization is in effect at the beginning of execution. This, combined
1402 with "PERL_HASH_SEED" and "PERL_PERTURB_KEYS" is intended to aid in
1403 debugging nondeterministic behaviour caused by hash randomization.
1404 .Sp
1405 \&\fBNote\fR that any information about the hash function, especially the hash
1406 seed is \fBsensitive information\fR: by knowing it, one can craft a denial\-of\-service
1407 attack against Perl code, even remotely; see "Algorithmic Complexity Attacks" in perlsec
1408 for more information. \fBDo not disclose the hash seed\fR to people who
1409 don\*(Aqt need to know it. See also \f(CWhash_seed()\fR and
1410 \&\f(CWhash_traversal_mask()\fR.
1411 .Sp
1412 An example output might be:
1413 .Sp
1414 .Vb 1
1415 \& HASH_FUNCTION = ONE_AT_A_TIME_HARD HASH_SEED = 0x652e9b9349a7a032 PERTURB_KEYS = 1 (RANDOM)
1416 .Ve
1417 .IP PERL_MEM_LOG 12
1418 .IX Xref "PERL_MEM_LOG"
1419 .IX Item "PERL_MEM_LOG"
1420 If your Perl was configured with \fB\-Accflags=\-DPERL_MEM_LOG\fR, setting
1421 the environment variable \f(CW\*(C`PERL_MEM_LOG\*(C'\fR enables logging debug
1422 messages. The value has the form \f(CW\*(C`<\fR\f(CInumber\fR\f(CW>[m][s][t]\*(C'\fR, where
1423 \&\f(CW\*(C`\fR\f(CInumber\fR\f(CW\*(C'\fR is the file descriptor number you want to write to (2 is
1424 default), and the combination of letters specifies that you want
1425 information about (m)emory and/or (s)v, optionally with
1426 (t)imestamps. For example, \f(CW\*(C`PERL_MEM_LOG=1mst\*(C'\fR logs all
1427 information to stdout. You can write to other opened file descriptors
1428 in a variety of ways:
1429 .Sp
1430 .Vb 1
1431 \& $ 3>foo3 PERL_MEM_LOG=3m perl ...
1432 .Ve
1433 .IP "PERL_ROOT (specific to the VMS port)" 12
1434 .IX Xref "PERL_ROOT"
1435 .IX Item "PERL_ROOT (specific to the VMS port)"
1436 A translation\-concealed rooted logical name that contains Perl and the
1437 logical device for the \f(CW@INC\fR path on VMS only. Other logical names that
1438 affect Perl on VMS include PERLSHR, PERL_ENV_TABLES, and
1439 SYS$TIMEZONE_DIFFERENTIAL, but are optional and discussed further in
1440 perlvms and in \fIREADME.vms\fR in the Perl source distribution.
1441 .IP PERL_SIGNALS 12
1442 .IX Xref "PERL_SIGNALS"
1443 .IX Item "PERL_SIGNALS"
1444 Available in Perls 5.8.1 and later. If set to \f(CW"unsafe"\fR, the pre\-Perl\-5.8.0
1445 signal behaviour (which is immediate but unsafe) is restored. If set
1446 to \f(CW\*(C`safe\*(C'\fR, then safe (but deferred) signals are used. See
1447 "Deferred Signals (Safe Signals)" in perlipc.
1448 .IP PERL_UNICODE 12
1449 .IX Xref "PERL_UNICODE"
1450 .IX Item "PERL_UNICODE"
1451 Equivalent to the \-C command\-line switch. Note
1452 that this is not a boolean variable. Setting this to \f(CW"1"\fR is not the
1453 right way to "enable Unicode" (whatever that would mean). You can use
1454 \&\f(CW"0"\fR to "disable Unicode", though (or alternatively unset PERL_UNICODE
1455 in your shell before starting Perl). See the description of the
1456 \&\-C switch for more information.
1457 .IP PERL_USE_UNSAFE_INC 12
1458 .IX Xref "PERL_USE_UNSAFE_INC"
1459 .IX Item "PERL_USE_UNSAFE_INC"
1460 If perl has been configured to not have the current directory in
1461 \&\f(CW@INC\fR by default, this variable can be set to \f(CW"1"\fR
1462 to reinstate it. It\*(Aqs primarily intended for use while building and
1463 testing modules that have not been updated to deal with "." not being in
1464 \&\f(CW@INC\fR and should not be set in the environment for day\-to\-day use.
1465 .IP "SYS$LOGIN (specific to the VMS port)" 12
1466 .IX Xref "SYS$LOGIN"
1467 .IX Item "SYS$LOGIN (specific to the VMS port)"
1468 Used if chdir has no argument and "HOME" and "LOGDIR" are not set.
1469 .IP PERL_INTERNAL_RAND_SEED 12
1470 .IX Xref "PERL_INTERNAL_RAND_SEED"
1471 .IX Item "PERL_INTERNAL_RAND_SEED"
1472 Set to a non\-negative integer to seed the random number generator used
1473 internally by perl for a variety of purposes.
1474 .Sp
1475 Ignored if perl is run setuid or setgid. Used only for some limited
1476 startup randomization (hash keys) if \f(CW\*(C`\-T\*(C'\fR or \f(CW\*(C`\-t\*(C'\fR perl is started
1477 with tainting enabled.
1478 .Sp
1479 Perl may be built to ignore this variable.
1480 .IP PERL_RAND_SEED 12
1481 .IX Xref "PERL_RAND_SEED"
1482 .IX Item "PERL_RAND_SEED"
1483 When set to an integer value this value will be used to seed the perl
1484 internal random number generator used for \f(CWrand()\fR when it is used
1485 without an explicit \f(CWsrand()\fR call or for when an explicit no\-argument
1486 \&\f(CWsrand()\fR call is made.
1487 .Sp
1488 Normally calling \f(CWrand()\fR prior to calling \f(CWsrand()\fR or calling
1489 \&\f(CWsrand()\fR explicitly with no arguments should result in the random
1490 number generator using "best efforts" to seed the generator state with a
1491 relatively high quality random seed. When this environment variable is
1492 set then the seeds used will be deterministically computed from the
1493 value provided in the env var in such a way that the application process
1494 and any forks or threads should continue to have their own unique seed but
1495 that the program may be run twice with identical results as far as
1496 \&\f(CWrand()\fR goes (assuming all else is equal).
1497 .Sp
1498 PERL_RAND_SEED is intended for performance measurements and debugging
1499 and is explicitly NOT intended for stable testing. The only guarantee is
1500 that a specific perl executable will produce the same results twice in a
1501 row, there is no guarantee that the results will be the same between
1502 perl releases or on different architectures.
1503 .Sp
1504 Ignored if perl is run setuid or setgid.
1505 .PP
1506 Perl also has environment variables that control how Perl handles data
1507 specific to particular natural languages; see perllocale.
1508 .PP
1509 Perl and its various modules and components, including its test frameworks,
1510 may sometimes make use of certain other environment variables. Some of
1511 these are specific to a particular platform. Please consult the
1512 appropriate module documentation and any documentation for your platform
1513 (like perlsolaris, perllinux, perlmacosx, perlwin32, etc) for
1514 variables peculiar to those specific situations.
1515 .PP
1516 Perl makes all environment variables available to the program being
1517 executed, and passes these along to any child processes it starts.
1518 However, programs running setuid would do well to execute the following
1519 lines before doing anything else, just to keep people honest:
1520 .PP
1521 .Vb 3
1522 \& $ENV{PATH} = "/bin:/usr/bin"; # or whatever you need
1523 \& $ENV{SHELL} = "/bin/sh" if exists $ENV{SHELL};
1524 \& delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
1525 .Ve
1526 .SH "ORDER OF APPLICATION"
1527 .IX Header "ORDER OF APPLICATION"
1528 Some options, in particular \f(CW\*(C`\-I\*(C'\fR, \f(CW\*(C`\-M\*(C'\fR, \f(CW\*(C`PERL5LIB\*(C'\fR and \f(CW\*(C`PERL5OPT\*(C'\fR can
1529 interact, and the order in which they are applied is important.
1530 .PP
1531 Note that this section does not document what \fIactually\fR happens inside the
1532 perl interpreter, it documents what \fIeffectively\fR happens.
1533 .IP \-I 4
1534 .IX Item "-I"
1535 The effect of multiple \f(CW\*(C`\-I\*(C'\fR options is to \f(CW\*(C`unshift\*(C'\fR them onto \f(CW@INC\fR
1536 from right to left. So for example:
1537 .Sp
1538 .Vb 1
1539 \& perl \-I 1 \-I 2 \-I 3
1540 .Ve
1541 .Sp
1542 will first prepend \f(CW3\fR onto the front of \f(CW@INC\fR, then prepend \f(CW2\fR, and
1543 then prepend \f(CW1\fR. The result is that \f(CW@INC\fR begins with:
1544 .Sp
1545 .Vb 1
1546 \& qw(1 2 3)
1547 .Ve
1548 .IP \-M 4
1549 .IX Item "-M"
1550 Multiple \f(CW\*(C`\-M\*(C'\fR options are processed from left to right. So this:
1551 .Sp
1552 .Vb 1
1553 \& perl \-Mlib=1 \-Mlib=2 \-Mlib=3
1554 .Ve
1555 .Sp
1556 will first use the lib pragma to prepend \f(CW1\fR to \f(CW@INC\fR, then
1557 it will prepend \f(CW2\fR, then it will prepend \f(CW3\fR, resulting in an \f(CW@INC\fR
1558 that begins with:
1559 .Sp
1560 .Vb 1
1561 \& qw(3 2 1)
1562 .Ve
1563 .IP "the PERL5LIB environment variable" 4
1564 .IX Item "the PERL5LIB environment variable"
1565 This contains a list of directories, separated by colons. The entire list
1566 is prepended to \f(CW@INC\fR in one go. This:
1567 .Sp
1568 .Vb 1
1569 \& PERL5LIB=1:2:3 perl
1570 .Ve
1571 .Sp
1572 will result in an \f(CW@INC\fR that begins with:
1573 .Sp
1574 .Vb 1
1575 \& qw(1 2 3)
1576 .Ve
1577 .IP "combinations of \-I, \-M and PERL5LIB" 4
1578 .IX Item "combinations of -I, -M and PERL5LIB"
1579 \&\f(CW\*(C`PERL5LIB\*(C'\fR is applied first, then all the \f(CW\*(C`\-I\*(C'\fR arguments, then all the
1580 \&\f(CW\*(C`\-M\*(C'\fR arguments. This:
1581 .Sp
1582 .Vb 1
1583 \& PERL5LIB=e1:e2 perl \-I i1 \-Mlib=m1 \-I i2 \-Mlib=m2
1584 .Ve
1585 .Sp
1586 will result in an \f(CW@INC\fR that begins with:
1587 .Sp
1588 .Vb 1
1589 \& qw(m2 m1 i1 i2 e1 e2)
1590 .Ve
1591 .IP "the PERL5OPT environment variable" 4
1592 .IX Item "the PERL5OPT environment variable"
1593 This contains a space separated list of switches. We only consider the
1594 effects of \f(CW\*(C`\-M\*(C'\fR and \f(CW\*(C`\-I\*(C'\fR in this section.
1595 .Sp
1596 After normal processing of \f(CW\*(C`\-I\*(C'\fR switches from the command line, all
1597 the \f(CW\*(C`\-I\*(C'\fR switches in \f(CW\*(C`PERL5OPT\*(C'\fR are extracted. They are processed from
1598 left to right instead of from right to left. Also note that while
1599 whitespace is allowed between a \f(CW\*(C`\-I\*(C'\fR and its directory on the command
1600 line, it is not allowed in \f(CW\*(C`PERL5OPT\*(C'\fR.
1601 .Sp
1602 After normal processing of \f(CW\*(C`\-M\*(C'\fR switches from the command line, all
1603 the \f(CW\*(C`\-M\*(C'\fR switches in \f(CW\*(C`PERL5OPT\*(C'\fR are extracted. They are processed from
1604 left to right, \fIi.e.\fR the same as those on the command line.
1605 .Sp
1606 An example may make this clearer:
1607 .Sp
1608 .Vb 3
1609 \& export PERL5OPT="\-Mlib=optm1 \-Iopti1 \-Mlib=optm2 \-Iopti2"
1610 \& export PERL5LIB=e1:e2
1611 \& perl \-I i1 \-Mlib=m1 \-I i2 \-Mlib=m2
1612 .Ve
1613 .Sp
1614 will result in an \f(CW@INC\fR that begins with:
1615 .Sp
1616 .Vb 3
1617 \& qw(
1618 \& optm2
1619 \& optm1
1620 \&
1621 \& m2
1622 \& m1
1623 \&
1624 \& opti2
1625 \& opti1
1626 \&
1627 \& i1
1628 \& i2
1629 \&
1630 \& e1
1631 \& e2
1632 \& )
1633 .Ve
1634 .IP "Other complications" 4
1635 .IX Item "Other complications"
1636 There are some complications that are ignored in the examples above:
1637 .RS 4
1638 .IP "arch and version subdirs" 4
1639 .IX Item "arch and version subdirs"
1640 All of \f(CW\*(C`\-I\*(C'\fR, \f(CW\*(C`PERL5LIB\*(C'\fR and \f(CW\*(C`use lib\*(C'\fR will also prepend arch and version
1641 subdirs if they are present
1642 .IP sitecustomize.pl 4
1643 .IX Item "sitecustomize.pl"
1644 .RE
1645 .RS 4
1646 .RE