1PERLRUN(1) Perl Programmers Reference Guide PERLRUN(1)
2
3
4
6 perlrun - how to execute the Perl interpreter
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] ] [ -S ] [ -x[dir] ]
14 [ -i[extension] ]
15 [ [-e|-E] 'command' ] [ -- ] [ programfile ] [ argument ]...
16
18 The normal way to run a Perl program is by making it directly
19 executable, or else by passing the name of the source file as an
20 argument on the command line. (An interactive Perl environment is also
21 possible--see perldebug for details on how to do that.) Upon startup,
22 Perl looks for your program in one of the following places:
23
24 1. Specified line by line via -e or -E switches on the command line.
25
26 2. Contained in the file specified by the first filename on the
27 command line. (Note that systems supporting the "#!" notation
28 invoke interpreters this way. See "Location of Perl".)
29
30 3. Passed in implicitly via standard input. This works only if there
31 are no filename arguments--to pass arguments to a STDIN-read
32 program you must explicitly specify a "-" for the program name.
33
34 With methods 2 and 3, Perl starts parsing the input file from the
35 beginning, unless you've specified a -x switch, in which case it scans
36 for the first line starting with "#!" and containing the word "perl",
37 and starts there instead. This is useful for running a program
38 embedded in a larger message. (In this case you would indicate the end
39 of the program using the "__END__" token.)
40
41 The "#!" line is always examined for switches as the line is being
42 parsed. Thus, if you're on a machine that allows only one argument
43 with the "#!" line, or worse, doesn't even recognize the "#!" line, you
44 still can get consistent switch behaviour regardless of how Perl was
45 invoked, even if -x was used to find the beginning of the program.
46
47 Because historically some operating systems silently chopped off kernel
48 interpretation of the "#!" line after 32 characters, some switches may
49 be passed in on the command line, and some may not; you could even get
50 a "-" without its letter, if you're not careful. You probably want to
51 make sure that all your switches fall either before or after that
52 32-character boundary. Most switches don't actually care if they're
53 processed redundantly, but getting a "-" instead of a complete switch
54 could cause Perl to try to execute standard input instead of your
55 program. And a partial -I switch could also cause odd results.
56
57 Some switches do care if they are processed twice, for instance
58 combinations of -l and -0. Either put all the switches after the
59 32-character boundary (if applicable), or replace the use of -0digits
60 by "BEGIN{ $/ = "\0digits"; }".
61
62 Parsing of the "#!" switches starts wherever "perl" is mentioned in the
63 line. The sequences "-*" and "- " are specifically ignored so that you
64 could, if you were so inclined, say
65
66 #!/bin/sh
67 #! -*-perl-*-
68 eval 'exec perl -x -wS $0 ${1+"$@"}'
69 if 0;
70
71 to let Perl see the -p switch.
72
73 A similar trick involves the env program, if you have it.
74
75 #!/usr/bin/env perl
76
77 The examples above use a relative path to the perl interpreter, getting
78 whatever version is first in the user's path. If you want a specific
79 version of Perl, say, perl5.14.1, you should place that directly in the
80 "#!" line's path.
81
82 If the "#!" line does not contain the word "perl" nor the word "indir",
83 the program named after the "#!" is executed instead of the Perl
84 interpreter. This is slightly bizarre, but it helps people on machines
85 that don't do "#!", because they can tell a program that their SHELL is
86 /usr/bin/perl, and Perl will then dispatch the program to the correct
87 interpreter for them.
88
89 After locating your program, Perl compiles the entire program to an
90 internal form. If there are any compilation errors, execution of the
91 program is not attempted. (This is unlike the typical shell script,
92 which might run part-way through before finding a syntax error.)
93
94 If the program is syntactically correct, it is executed. If the
95 program runs off the end without hitting an exit() or die() operator,
96 an implicit exit(0) is provided to indicate successful completion.
97
98 #! and quoting on non-Unix systems
99 Unix's "#!" technique can be simulated on other systems:
100
101 OS/2
102 Put
103
104 extproc perl -S -your_switches
105
106 as the first line in "*.cmd" file (-S due to a bug in cmd.exe's
107 `extproc' handling).
108
109 MS-DOS
110 Create a batch file to run your program, and codify it in
111 "ALTERNATE_SHEBANG" (see the dosish.h file in the source
112 distribution for more information).
113
114 Win95/NT
115 The Win95/NT installation, when using the ActiveState installer for
116 Perl, will modify the Registry to associate the .pl extension with
117 the perl interpreter. If you install Perl by other means
118 (including building from the sources), you may have to modify the
119 Registry yourself. Note that this means you can no longer tell the
120 difference between an executable Perl program and a Perl library
121 file.
122
123 VMS Put
124
125 $ perl -mysw 'f$env("procedure")' 'p1' 'p2' 'p3' 'p4' 'p5' 'p6' 'p7' 'p8' !
126 $ exit++ + ++$status != 0 and $exit = $status = undef;
127
128 at the top of your program, where -mysw are any command line
129 switches you want to pass to Perl. You can now invoke the program
130 directly, by saying "perl program", or as a DCL procedure, by
131 saying @program (or implicitly via DCL$PATH by just using the name
132 of the program).
133
134 This incantation is a bit much to remember, but Perl will display
135 it for you if you say "perl "-V:startperl"".
136
137 Command-interpreters on non-Unix systems have rather different ideas on
138 quoting than Unix shells. You'll need to learn the special characters
139 in your command-interpreter ("*", "\" and """ are common) and how to
140 protect whitespace and these characters to run one-liners (see -e
141 below).
142
143 On some systems, you may have to change single-quotes to double ones,
144 which you must not do on Unix or Plan 9 systems. You might also have
145 to change a single % to a %%.
146
147 For example:
148
149 # Unix
150 perl -e 'print "Hello world\n"'
151
152 # MS-DOS, etc.
153 perl -e "print \"Hello world\n\""
154
155 # VMS
156 perl -e "print ""Hello world\n"""
157
158 The problem is that none of this is reliable: it depends on the command
159 and it is entirely possible neither works. If 4DOS were the command
160 shell, this would probably work better:
161
162 perl -e "print <Ctrl-x>"Hello world\n<Ctrl-x>""
163
164 CMD.EXE in Windows NT slipped a lot of standard Unix functionality in
165 when nobody was looking, but just try to find documentation for its
166 quoting rules.
167
168 There is no general solution to all of this. It's just a mess.
169
170 Location of Perl
171 It may seem obvious to say, but Perl is useful only when users can
172 easily find it. When possible, it's good for both /usr/bin/perl and
173 /usr/local/bin/perl to be symlinks to the actual binary. If that can't
174 be done, system administrators are strongly encouraged to put (symlinks
175 to) perl and its accompanying utilities into a directory typically
176 found along a user's PATH, or in some other obvious and convenient
177 place.
178
179 In this documentation, "#!/usr/bin/perl" on the first line of the
180 program will stand in for whatever method works on your system. You
181 are advised to use a specific path if you care about a specific
182 version.
183
184 #!/usr/local/bin/perl5.14
185
186 or if you just want to be running at least version, place a statement
187 like this at the top of your program:
188
189 use 5.014;
190
191 Command Switches
192 As with all standard commands, a single-character switch may be
193 clustered with the following switch, if any.
194
195 #!/usr/bin/perl -spi.orig # same as -s -p -i.orig
196
197 A "--" signals the end of options and disables further option
198 processing. Any arguments after the "--" are treated as filenames and
199 arguments.
200
201 Switches include:
202
203 -0[octal/hexadecimal]
204 specifies the input record separator ($/) as an octal or
205 hexadecimal number. If there are no digits, the null character is
206 the separator. Other switches may precede or follow the digits.
207 For example, if you have a version of find which can print
208 filenames terminated by the null character, you can say this:
209
210 find . -name '*.orig' -print0 | perl -n0e unlink
211
212 The special value 00 will cause Perl to slurp files in paragraph
213 mode. Any value 0400 or above will cause Perl to slurp files
214 whole, but by convention the value 0777 is the one normally used
215 for this purpose.
216
217 You can also specify the separator character using hexadecimal
218 notation: -0xHHH..., where the "H" are valid hexadecimal digits.
219 Unlike the octal form, this one may be used to specify any Unicode
220 character, even those beyond 0xFF. So if you really want a record
221 separator of 0777, specify it as -0x1FF. (This means that you
222 cannot use the -x option with a directory name that consists of
223 hexadecimal digits, or else Perl will think you have specified a
224 hex number to -0.)
225
226 -a turns on autosplit mode when used with a -n or -p. An implicit
227 split command to the @F array is done as the first thing inside
228 the implicit while loop produced by the -n or -p.
229
230 perl -ane 'print pop(@F), "\n";'
231
232 is equivalent to
233
234 while (<>) {
235 @F = split(' ');
236 print pop(@F), "\n";
237 }
238
239 An alternate delimiter may be specified using -F.
240
241 -a implicitly sets -n.
242
243 -C [number/list]
244 The -C flag controls some of the Perl Unicode features.
245
246 As of 5.8.1, the -C can be followed either by a number or a list
247 of option letters. The letters, their numeric values, and effects
248 are as follows; listing the letters is equal to summing the
249 numbers.
250
251 I 1 STDIN is assumed to be in UTF-8
252 O 2 STDOUT will be in UTF-8
253 E 4 STDERR will be in UTF-8
254 S 7 I + O + E
255 i 8 UTF-8 is the default PerlIO layer for input streams
256 o 16 UTF-8 is the default PerlIO layer for output streams
257 D 24 i + o
258 A 32 the @ARGV elements are expected to be strings encoded
259 in UTF-8
260 L 64 normally the "IOEioA" are unconditional, the L makes
261 them conditional on the locale environment variables
262 (the LC_ALL, LC_CTYPE, and LANG, in the order of
263 decreasing precedence) -- if the variables indicate
264 UTF-8, then the selected "IOEioA" are in effect
265 a 256 Set ${^UTF8CACHE} to -1, to run the UTF-8 caching
266 code in debugging mode.
267
268 For example, -COE and -C6 will both turn on UTF-8-ness on both
269 STDOUT and STDERR. Repeating letters is just redundant, not
270 cumulative nor toggling.
271
272 The "io" options mean that any subsequent open() (or similar I/O
273 operations) in the current file scope will have the ":utf8" PerlIO
274 layer implicitly applied to them, in other words, UTF-8 is
275 expected from any input stream, and UTF-8 is produced to any
276 output stream. This is just the default, with explicit layers in
277 open() and with binmode() one can manipulate streams as usual.
278
279 -C on its own (not followed by any number or option list), or the
280 empty string "" for the "PERL_UNICODE" environment variable, has
281 the same effect as -CSDL. In other words, the standard I/O
282 handles and the default "open()" layer are UTF-8-fied but only if
283 the locale environment variables indicate a UTF-8 locale. This
284 behaviour follows the implicit (and problematic) UTF-8 behaviour
285 of Perl 5.8.0. (See "UTF-8 no longer default under UTF-8 locales"
286 in perl581delta.)
287
288 You can use -C0 (or "0" for "PERL_UNICODE") to explicitly disable
289 all the above Unicode features.
290
291 The read-only magic variable "${^UNICODE}" reflects the numeric
292 value of this setting. This variable is set during Perl startup
293 and is thereafter read-only. If you want runtime effects, use the
294 three-arg open() (see "open" in perlfunc), the two-arg binmode()
295 (see "binmode" in perlfunc), and the "open" pragma (see open).
296
297 (In Perls earlier than 5.8.1 the -C switch was a Win32-only switch
298 that enabled the use of Unicode-aware "wide system call" Win32
299 APIs. This feature was practically unused, however, and the
300 command line switch was therefore "recycled".)
301
302 Note: Since perl 5.10.1, if the -C option is used on the "#!"
303 line, it must be specified on the command line as well, since the
304 standard streams are already set up at this point in the execution
305 of the perl interpreter. You can also use binmode() to set the
306 encoding of an I/O stream.
307
308 -c causes Perl to check the syntax of the program and then exit
309 without executing it. Actually, it will execute any "BEGIN",
310 "UNITCHECK", or "CHECK" blocks and any "use" statements: these are
311 considered as occurring outside the execution of your program.
312 "INIT" and "END" blocks, however, will be skipped.
313
314 -d
315 -dt runs the program under the Perl debugger. See perldebug. If t is
316 specified, it indicates to the debugger that threads will be used
317 in the code being debugged.
318
319 -d:MOD[=bar,baz]
320 -dt:MOD[=bar,baz]
321 runs the program under the control of a debugging, profiling, or
322 tracing module installed as "Devel::MOD". E.g., -d:DProf executes
323 the program using the "Devel::DProf" profiler. As with the -M
324 flag, options may be passed to the "Devel::MOD" package where they
325 will be received and interpreted by the "Devel::MOD::import"
326 routine. Again, like -M, use --d:-MOD to call
327 "Devel::MOD::unimport" instead of import. The comma-separated
328 list of options must follow a "=" character. If t is specified,
329 it indicates to the debugger that threads will be used in the code
330 being debugged. See perldebug.
331
332 -Dletters
333 -Dnumber
334 sets debugging flags. This switch is enabled only if your perl
335 binary has been built with debugging enabled: normal production
336 perls won't have been.
337
338 For example, to watch how perl executes your program, use -Dtls.
339 Another nice value is -Dx, which lists your compiled syntax tree,
340 and -Dr displays compiled regular expressions; the format of the
341 output is explained in perldebguts.
342
343 As an alternative, specify a number instead of list of letters
344 (e.g., -D14 is equivalent to -Dtls):
345
346 1 p Tokenizing and parsing (with v, displays parse
347 stack)
348 2 s Stack snapshots (with v, displays all stacks)
349 4 l Context (loop) stack processing
350 8 t Trace execution
351 16 o Method and overloading resolution
352 32 c String/numeric conversions
353 64 P Print profiling info, source file input state
354 128 m Memory and SV allocation
355 256 f Format processing
356 512 r Regular expression parsing and execution
357 1024 x Syntax tree dump
358 2048 u Tainting checks
359 4096 U Unofficial, User hacking (reserved for private,
360 unreleased use)
361 16384 X Scratchpad allocation
362 32768 D Cleaning up
363 65536 S Op slab allocation
364 131072 T Tokenizing
365 262144 R Include reference counts of dumped variables
366 (eg when using -Ds)
367 524288 J show s,t,P-debug (don't Jump over) on opcodes within
368 package DB
369 1048576 v Verbose: use in conjunction with other flags
370 2097152 C Copy On Write
371 4194304 A Consistency checks on internal structures
372 8388608 q quiet - currently only suppresses the "EXECUTING"
373 message
374 16777216 M trace smart match resolution
375 33554432 B dump suBroutine definitions, including special
376 Blocks like BEGIN
377 67108864 L trace Locale-related info; what gets output is very
378 subject to change
379 134217728 i trace PerlIO layer processing. Set PERLIO_DEBUG to
380 the filename to trace to.
381
382 All these flags require -DDEBUGGING when you compile the Perl
383 executable (but see ":opd" in Devel::Peek or "'debug' mode" in re
384 which may change this). See the INSTALL file in the Perl source
385 distribution for how to do this.
386
387 If you're just trying to get a print out of each line of Perl code
388 as it executes, the way that "sh -x" provides for shell scripts,
389 you can't use Perl's -D switch. Instead do this
390
391 # If you have "env" utility
392 env PERLDB_OPTS="NonStop=1 AutoTrace=1 frame=2" perl -dS program
393
394 # Bourne shell syntax
395 $ PERLDB_OPTS="NonStop=1 AutoTrace=1 frame=2" perl -dS program
396
397 # csh syntax
398 % (setenv PERLDB_OPTS "NonStop=1 AutoTrace=1 frame=2"; perl -dS program)
399
400 See perldebug for details and variations.
401
402 -e commandline
403 may be used to enter one line of program. If -e is given, Perl
404 will not look for a filename in the argument list. Multiple -e
405 commands may be given to build up a multi-line script. Make sure
406 to use semicolons where you would in a normal program.
407
408 -E commandline
409 behaves just like -e, except that it implicitly enables all
410 optional features (in the main compilation unit). See feature.
411
412 -f Disable executing $Config{sitelib}/sitecustomize.pl at startup.
413
414 Perl can be built so that it by default will try to execute
415 $Config{sitelib}/sitecustomize.pl at startup (in a BEGIN block).
416 This is a hook that allows the sysadmin to customize how Perl
417 behaves. It can for instance be used to add entries to the @INC
418 array to make Perl find modules in non-standard locations.
419
420 Perl actually inserts the following code:
421
422 BEGIN {
423 do { local $!; -f "$Config{sitelib}/sitecustomize.pl"; }
424 && do "$Config{sitelib}/sitecustomize.pl";
425 }
426
427 Since it is an actual "do" (not a "require"), sitecustomize.pl
428 doesn't need to return a true value. The code is run in package
429 "main", in its own lexical scope. However, if the script dies, $@
430 will not be set.
431
432 The value of $Config{sitelib} is also determined in C code and not
433 read from "Config.pm", which is not loaded.
434
435 The code is executed very early. For example, any changes made to
436 @INC will show up in the output of `perl -V`. Of course, "END"
437 blocks will be likewise executed very late.
438
439 To determine at runtime if this capability has been compiled in
440 your perl, you can check the value of $Config{usesitecustomize}.
441
442 -Fpattern
443 specifies the pattern to split on for -a. The pattern may be
444 surrounded by "//", "", or '', otherwise it will be put in single
445 quotes. You can't use literal whitespace or NUL characters in the
446 pattern.
447
448 -F implicitly sets both -a and -n.
449
450 -h prints a summary of the options.
451
452 -i[extension]
453 specifies that files processed by the "<>" construct are to be
454 edited in-place. It does this by renaming the input file, opening
455 the output file by the original name, and selecting that output
456 file as the default for print() statements. The extension, if
457 supplied, is used to modify the name of the old file to make a
458 backup copy, following these rules:
459
460 If no extension is supplied, and your system supports it, the
461 original file is kept open without a name while the output is
462 redirected to a new file with the original filename. When perl
463 exits, cleanly or not, the original file is unlinked.
464
465 If the extension doesn't contain a "*", then it is appended to the
466 end of the current filename as a suffix. If the extension does
467 contain one or more "*" characters, then each "*" is replaced with
468 the current filename. In Perl terms, you could think of this as:
469
470 ($backup = $extension) =~ s/\*/$file_name/g;
471
472 This allows you to add a prefix to the backup file, instead of (or
473 in addition to) a suffix:
474
475 $ perl -pi'orig_*' -e 's/bar/baz/' fileA # backup to
476 # 'orig_fileA'
477
478 Or even to place backup copies of the original files into another
479 directory (provided the directory already exists):
480
481 $ perl -pi'old/*.orig' -e 's/bar/baz/' fileA # backup to
482 # 'old/fileA.orig'
483
484 These sets of one-liners are equivalent:
485
486 $ perl -pi -e 's/bar/baz/' fileA # overwrite current file
487 $ perl -pi'*' -e 's/bar/baz/' fileA # overwrite current file
488
489 $ perl -pi'.orig' -e 's/bar/baz/' fileA # backup to 'fileA.orig'
490 $ perl -pi'*.orig' -e 's/bar/baz/' fileA # backup to 'fileA.orig'
491
492 From the shell, saying
493
494 $ perl -p -i.orig -e "s/foo/bar/; ... "
495
496 is the same as using the program:
497
498 #!/usr/bin/perl -pi.orig
499 s/foo/bar/;
500
501 which is equivalent to
502
503 #!/usr/bin/perl
504 $extension = '.orig';
505 LINE: while (<>) {
506 if ($ARGV ne $oldargv) {
507 if ($extension !~ /\*/) {
508 $backup = $ARGV . $extension;
509 }
510 else {
511 ($backup = $extension) =~ s/\*/$ARGV/g;
512 }
513 rename($ARGV, $backup);
514 open(ARGVOUT, ">$ARGV");
515 select(ARGVOUT);
516 $oldargv = $ARGV;
517 }
518 s/foo/bar/;
519 }
520 continue {
521 print; # this prints to original filename
522 }
523 select(STDOUT);
524
525 except that the -i form doesn't need to compare $ARGV to $oldargv
526 to know when the filename has changed. It does, however, use
527 ARGVOUT for the selected filehandle. Note that STDOUT is restored
528 as the default output filehandle after the loop.
529
530 As shown above, Perl creates the backup file whether or not any
531 output is actually changed. So this is just a fancy way to copy
532 files:
533
534 $ perl -p -i'/some/file/path/*' -e 1 file1 file2 file3...
535 or
536 $ perl -p -i'.orig' -e 1 file1 file2 file3...
537
538 You can use "eof" without parentheses to locate the end of each
539 input file, in case you want to append to each file, or reset line
540 numbering (see example in "eof" in perlfunc).
541
542 If, for a given file, Perl is unable to create the backup file as
543 specified in the extension then it will skip that file and
544 continue on with the next one (if it exists).
545
546 For a discussion of issues surrounding file permissions and -i,
547 see "Why does Perl let me delete read-only files? Why does -i
548 clobber protected files? Isn't this a bug in Perl?" in perlfaq5.
549
550 You cannot use -i to create directories or to strip extensions
551 from files.
552
553 Perl does not expand "~" in filenames, which is good, since some
554 folks use it for their backup files:
555
556 $ perl -pi~ -e 's/foo/bar/' file1 file2 file3...
557
558 Note that because -i renames or deletes the original file before
559 creating a new file of the same name, Unix-style soft and hard
560 links will not be preserved.
561
562 Finally, the -i switch does not impede execution when no files are
563 given on the command line. In this case, no backup is made (the
564 original file cannot, of course, be determined) and processing
565 proceeds from STDIN to STDOUT as might be expected.
566
567 -Idirectory
568 Directories specified by -I are prepended to the search path for
569 modules (@INC).
570
571 -l[octnum]
572 enables automatic line-ending processing. It has two separate
573 effects. First, it automatically chomps $/ (the input record
574 separator) when used with -n or -p. Second, it assigns "$\" (the
575 output record separator) to have the value of octnum so that any
576 print statements will have that separator added back on. If
577 octnum is omitted, sets "$\" to the current value of $/. For
578 instance, to trim lines to 80 columns:
579
580 perl -lpe 'substr($_, 80) = ""'
581
582 Note that the assignment "$\ = $/" is done when the switch is
583 processed, so the input record separator can be different than the
584 output record separator if the -l switch is followed by a -0
585 switch:
586
587 gnufind / -print0 | perl -ln0e 'print "found $_" if -p'
588
589 This sets "$\" to newline and then sets $/ to the null character.
590
591 -m[-]module
592 -M[-]module
593 -M[-]'module ...'
594 -[mM][-]module=arg[,arg]...
595 -mmodule executes "use" module "();" before executing your
596 program. This loads the module, but does not call its "import"
597 method, so does not import subroutines and does not give effect to
598 a pragma.
599
600 -Mmodule executes "use" module ";" before executing your program.
601 This loads the module and calls its "import" method, causing the
602 module to have its default effect, typically importing subroutines
603 or giving effect to a pragma. You can use quotes to add extra
604 code after the module name, e.g., '-MMODULE qw(foo bar)'.
605
606 If the first character after the -M or -m is a dash (-) then the
607 'use' is replaced with 'no'. This makes no difference for -m.
608
609 A little builtin syntactic sugar means you can also say
610 -mMODULE=foo,bar or -MMODULE=foo,bar as a shortcut for '-MMODULE
611 qw(foo bar)'. This avoids the need to use quotes when importing
612 symbols. The actual code generated by -MMODULE=foo,bar is "use
613 module split(/,/,q{foo,bar})". Note that the "=" form removes the
614 distinction between -m and -M; that is, -mMODULE=foo,bar is the
615 same as -MMODULE=foo,bar.
616
617 A consequence of the "split" formulation is that -MMODULE=number
618 never does a version check, unless "MODULE::import()" itself is
619 set up to do a version check, which could happen for example if
620 MODULE inherits from Exporter.
621
622 -n causes Perl to assume the following loop around your program,
623 which makes it iterate over filename arguments somewhat like sed
624 -n or awk:
625
626 LINE:
627 while (<>) {
628 ... # your program goes here
629 }
630
631 Note that the lines are not printed by default. See "-p" to have
632 lines printed. If a file named by an argument cannot be opened
633 for some reason, Perl warns you about it and moves on to the next
634 file.
635
636 Also note that "<>" passes command line arguments to "open" in
637 perlfunc, which doesn't necessarily interpret them as file names.
638 See perlop for possible security implications.
639
640 Here is an efficient way to delete all files that haven't been
641 modified for at least a week:
642
643 find . -mtime +7 -print | perl -nle unlink
644
645 This is faster than using the -exec switch of find because you
646 don't have to start a process on every filename found (but it's
647 not faster than using the -delete switch available in newer
648 versions of find. It does suffer from the bug of mishandling
649 newlines in pathnames, which you can fix if you follow the example
650 under -0.
651
652 "BEGIN" and "END" blocks may be used to capture control before or
653 after the implicit program loop, just as in awk.
654
655 -p causes Perl to assume the following loop around your program,
656 which makes it iterate over filename arguments somewhat like sed:
657
658 LINE:
659 while (<>) {
660 ... # your program goes here
661 } continue {
662 print or die "-p destination: $!\n";
663 }
664
665 If a file named by an argument cannot be opened for some reason,
666 Perl warns you about it, and moves on to the next file. Note that
667 the lines are printed automatically. An error occurring during
668 printing is treated as fatal. To suppress printing use the -n
669 switch. A -p overrides a -n switch.
670
671 "BEGIN" and "END" blocks may be used to capture control before or
672 after the implicit loop, just as in awk.
673
674 -s enables rudimentary switch parsing for switches on the command
675 line after the program name but before any filename arguments (or
676 before an argument of --). Any switch found there is removed from
677 @ARGV and sets the corresponding variable in the Perl program.
678 The following program prints "1" if the program is invoked with a
679 -xyz switch, and "abc" if it is invoked with -xyz=abc.
680
681 #!/usr/bin/perl -s
682 if ($xyz) { print "$xyz\n" }
683
684 Do note that a switch like --help creates the variable "${-help}",
685 which is not compliant with "use strict "refs"". Also, when using
686 this option on a script with warnings enabled you may get a lot of
687 spurious "used only once" warnings.
688
689 -S makes Perl use the PATH environment variable to search for the
690 program unless the name of the program contains path separators.
691
692 On some platforms, this also makes Perl append suffixes to the
693 filename while searching for it. For example, on Win32 platforms,
694 the ".bat" and ".cmd" suffixes are appended if a lookup for the
695 original name fails, and if the name does not already end in one
696 of those suffixes. If your Perl was compiled with "DEBUGGING"
697 turned on, using the -Dp switch to Perl shows how the search
698 progresses.
699
700 Typically this is used to emulate "#!" startup on platforms that
701 don't support "#!". It's also convenient when debugging a script
702 that uses "#!", and is thus normally found by the shell's $PATH
703 search mechanism.
704
705 This example works on many platforms that have a shell compatible
706 with Bourne shell:
707
708 #!/usr/bin/perl
709 eval 'exec /usr/bin/perl -wS $0 ${1+"$@"}'
710 if $running_under_some_shell;
711
712 The system ignores the first line and feeds the program to
713 /bin/sh, which proceeds to try to execute the Perl program as a
714 shell script. The shell executes the second line as a normal
715 shell command, and thus starts up the Perl interpreter. On some
716 systems $0 doesn't always contain the full pathname, so the -S
717 tells Perl to search for the program if necessary. After Perl
718 locates the program, it parses the lines and ignores them because
719 the variable $running_under_some_shell is never true. If the
720 program will be interpreted by csh, you will need to replace
721 "${1+"$@"}" with $*, even though that doesn't understand embedded
722 spaces (and such) in the argument list. To start up sh rather
723 than csh, some systems may have to replace the "#!" line with a
724 line containing just a colon, which will be politely ignored by
725 Perl. Other systems can't control that, and need a totally
726 devious construct that will work under any of csh, sh, or Perl,
727 such as the following:
728
729 eval '(exit $?0)' && eval 'exec perl -wS $0 ${1+"$@"}'
730 & eval 'exec /usr/bin/perl -wS $0 $argv:q'
731 if $running_under_some_shell;
732
733 If the filename supplied contains directory separators (and so is
734 an absolute or relative pathname), and if that file is not found,
735 platforms that append file extensions will do so and try to look
736 for the file with those extensions added, one by one.
737
738 On DOS-like platforms, if the program does not contain directory
739 separators, it will first be searched for in the current directory
740 before being searched for on the PATH. On Unix platforms, the
741 program will be searched for strictly on the PATH.
742
743 -t Like -T, but taint checks will issue warnings rather than fatal
744 errors. These warnings can now be controlled normally with "no
745 warnings qw(taint)".
746
747 Note: This is not a substitute for "-T"! This is meant to be used
748 only as a temporary development aid while securing legacy code:
749 for real production code and for new secure code written from
750 scratch, always use the real -T.
751
752 -T turns on "taint" so you can test them. Ordinarily these checks
753 are done only when running setuid or setgid. It's a good idea to
754 turn them on explicitly for programs that run on behalf of someone
755 else whom you might not necessarily trust, such as CGI programs or
756 any internet servers you might write in Perl. See perlsec for
757 details. For security reasons, this option must be seen by Perl
758 quite early; usually this means it must appear early on the
759 command line or in the "#!" line for systems which support that
760 construct.
761
762 -u This switch causes Perl to dump core after compiling your program.
763 You can then in theory take this core dump and turn it into an
764 executable file by using the undump program (not supplied). This
765 speeds startup at the expense of some disk space (which you can
766 minimize by stripping the executable). (Still, a "hello world"
767 executable comes out to about 200K on my machine.) If you want to
768 execute a portion of your program before dumping, use the dump()
769 operator instead. Note: availability of undump is platform
770 specific and may not be available for a specific port of Perl.
771
772 -U allows Perl to do unsafe operations. Currently the only "unsafe"
773 operations are attempting to unlink directories while running as
774 superuser and running setuid programs with fatal taint checks
775 turned into warnings. Note that warnings must be enabled along
776 with this option to actually generate the taint-check warnings.
777
778 -v prints the version and patchlevel of your perl executable.
779
780 -V prints summary of the major perl configuration values and the
781 current values of @INC.
782
783 -V:configvar
784 Prints to STDOUT the value of the named configuration variable(s),
785 with multiples when your "configvar" argument looks like a regex
786 (has non-letters). For example:
787
788 $ perl -V:libc
789 libc='/lib/libc-2.2.4.so';
790 $ perl -V:lib.
791 libs='-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc';
792 libc='/lib/libc-2.2.4.so';
793 $ perl -V:lib.*
794 libpth='/usr/local/lib /lib /usr/lib';
795 libs='-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc';
796 lib_ext='.a';
797 libc='/lib/libc-2.2.4.so';
798 libperl='libperl.a';
799 ....
800
801 Additionally, extra colons can be used to control formatting. A
802 trailing colon suppresses the linefeed and terminator ";",
803 allowing you to embed queries into shell commands. (mnemonic:
804 PATH separator ":".)
805
806 $ echo "compression-vars: " `perl -V:z.*: ` " are here !"
807 compression-vars: zcat='' zip='zip' are here !
808
809 A leading colon removes the "name=" part of the response, this
810 allows you to map to the name you need. (mnemonic: empty label)
811
812 $ echo "goodvfork="`./perl -Ilib -V::usevfork`
813 goodvfork=false;
814
815 Leading and trailing colons can be used together if you need
816 positional parameter values without the names. Note that in the
817 case below, the "PERL_API" params are returned in alphabetical
818 order.
819
820 $ echo building_on `perl -V::osname: -V::PERL_API_.*:` now
821 building_on 'linux' '5' '1' '9' now
822
823 -w prints warnings about dubious constructs, such as variable names
824 mentioned only once and scalar variables used before being set;
825 redefined subroutines; references to undefined filehandles;
826 filehandles opened read-only that you are attempting to write on;
827 values used as a number that don't look like numbers; using an
828 array as though it were a scalar; if your subroutines recurse more
829 than 100 deep; and innumerable other things.
830
831 This switch really just enables the global $^W variable; normally,
832 the lexically scoped "use warnings" pragma is preferred. You can
833 disable or promote into fatal errors specific warnings using
834 "__WARN__" hooks, as described in perlvar and "warn" in perlfunc.
835 See also perldiag and perltrap. A fine-grained warning facility
836 is also available if you want to manipulate entire classes of
837 warnings; see warnings.
838
839 -W Enables all warnings regardless of "no warnings" or $^W. See
840 warnings.
841
842 -X Disables all warnings regardless of "use warnings" or $^W. See
843 warnings.
844
845 -x
846 -xdirectory
847 tells Perl that the program is embedded in a larger chunk of
848 unrelated text, such as in a mail message. Leading garbage will
849 be discarded until the first line that starts with "#!" and
850 contains the string "perl". Any meaningful switches on that line
851 will be applied.
852
853 All references to line numbers by the program (warnings, errors,
854 ...) will treat the "#!" line as the first line. Thus a warning
855 on the 2nd line of the program, which is on the 100th line in the
856 file will be reported as line 2, not as line 100. This can be
857 overridden by using the "#line" directive. (See "Plain Old
858 Comments (Not!)" in perlsyn)
859
860 If a directory name is specified, Perl will switch to that
861 directory before running the program. The -x switch controls only
862 the disposal of leading garbage. The program must be terminated
863 with "__END__" if there is trailing garbage to be ignored; the
864 program can process any or all of the trailing garbage via the
865 "DATA" filehandle if desired.
866
867 The directory, if specified, must appear immediately following the
868 -x with no intervening whitespace.
869
871 HOME Used if "chdir" has no argument.
872
873 LOGDIR Used if "chdir" has no argument and HOME is not set.
874
875 PATH Used in executing subprocesses, and in finding the program
876 if -S is used.
877
878 PERL5LIB A list of directories in which to look for Perl library
879 files before looking in the standard library. Any
880 architecture-specific and version-specific directories,
881 such as version/archname/, version/, or archname/ under the
882 specified locations are automatically included if they
883 exist, with this lookup done at interpreter startup time.
884 In addition, any directories matching the entries in
885 $Config{inc_version_list} are added. (These typically
886 would be for older compatible perl versions installed in
887 the same directory tree.)
888
889 If PERL5LIB is not defined, PERLLIB is used. Directories
890 are separated (like in PATH) by a colon on Unixish
891 platforms and by a semicolon on Windows (the proper path
892 separator being given by the command "perl -V:path_sep").
893
894 When running taint checks, either because the program was
895 running setuid or setgid, or the -T or -t switch was
896 specified, neither PERL5LIB nor PERLLIB is consulted. The
897 program should instead say:
898
899 use lib "/my/directory";
900
901 PERL5OPT Command-line options (switches). Switches in this variable
902 are treated as if they were on every Perl command line.
903 Only the -[CDIMUdmtwW] switches are allowed. When running
904 taint checks (either because the program was running setuid
905 or setgid, or because the -T or -t switch was used), this
906 variable is ignored. If PERL5OPT begins with -T, tainting
907 will be enabled and subsequent options ignored. If
908 PERL5OPT begins with -t, tainting will be enabled, a
909 writable dot removed from @INC, and subsequent options
910 honored.
911
912 PERLIO A space (or colon) separated list of PerlIO layers. If perl
913 is built to use PerlIO system for IO (the default) these
914 layers affect Perl's IO.
915
916 It is conventional to start layer names with a colon (for
917 example, ":perlio") to emphasize their similarity to
918 variable "attributes". But the code that parses layer
919 specification strings, which is also used to decode the
920 PERLIO environment variable, treats the colon as a
921 separator.
922
923 An unset or empty PERLIO is equivalent to the default set
924 of layers for your platform; for example, ":unix:perlio" on
925 Unix-like systems and ":unix:crlf" on Windows and other
926 DOS-like systems.
927
928 The list becomes the default for all Perl's IO.
929 Consequently only built-in layers can appear in this list,
930 as external layers (such as ":encoding()") need IO in order
931 to load them! See "open pragma" for how to add external
932 encodings as defaults.
933
934 Layers it makes sense to include in the PERLIO environment
935 variable are briefly summarized below. For more details see
936 PerlIO.
937
938 :bytes A pseudolayer that turns the ":utf8" flag off for
939 the layer below; unlikely to be useful on its own
940 in the global PERLIO environment variable. You
941 perhaps were thinking of ":crlf:bytes" or
942 ":perlio:bytes".
943
944 :crlf A layer which does CRLF to "\n" translation
945 distinguishing "text" and "binary" files in the
946 manner of MS-DOS and similar operating systems.
947 (It currently does not mimic MS-DOS as far as
948 treating of Control-Z as being an end-of-file
949 marker.)
950
951 :mmap A layer that implements "reading" of files by using
952 mmap(2) to make an entire file appear in the
953 process's address space, and then using that as
954 PerlIO's "buffer".
955
956 :perlio This is a re-implementation of stdio-like buffering
957 written as a PerlIO layer. As such it will call
958 whatever layer is below it for its operations,
959 typically ":unix".
960
961 :pop An experimental pseudolayer that removes the
962 topmost layer. Use with the same care as is
963 reserved for nitroglycerine.
964
965 :raw A pseudolayer that manipulates other layers.
966 Applying the ":raw" layer is equivalent to calling
967 "binmode($fh)". It makes the stream pass each byte
968 as-is without translation. In particular, both
969 CRLF translation and intuiting ":utf8" from the
970 locale are disabled.
971
972 Unlike in earlier versions of Perl, ":raw" is not
973 just the inverse of ":crlf": other layers which
974 would affect the binary nature of the stream are
975 also removed or disabled.
976
977 :stdio This layer provides a PerlIO interface by wrapping
978 system's ANSI C "stdio" library calls. The layer
979 provides both buffering and IO. Note that the
980 ":stdio" layer does not do CRLF translation even if
981 that is the platform's normal behaviour. You will
982 need a ":crlf" layer above it to do that.
983
984 :unix Low-level layer that calls "read", "write",
985 "lseek", etc.
986
987 :utf8 A pseudolayer that enables a flag in the layer
988 below to tell Perl that output should be in utf8
989 and that input should be regarded as already in
990 valid utf8 form. WARNING: It does not check for
991 validity and as such should be handled with extreme
992 caution for input, because security violations can
993 occur with non-shortest UTF-8 encodings, etc.
994 Generally ":encoding(UTF-8)" is the best option
995 when reading UTF-8 encoded data.
996
997 :win32 On Win32 platforms this experimental layer uses
998 native "handle" IO rather than a Unix-like numeric
999 file descriptor layer. Known to be buggy in this
1000 release (5.14).
1001
1002 The default set of layers should give acceptable results on
1003 all platforms
1004
1005 For Unix platforms that will be the equivalent of "unix
1006 perlio" or "stdio". Configure is set up to prefer the
1007 "stdio" implementation if the system's library provides for
1008 fast access to the buffer; otherwise, it uses the "unix
1009 perlio" implementation.
1010
1011 On Win32 the default in this release (5.14) is "unix crlf".
1012 Win32's "stdio" has a number of bugs/mis-features for Perl
1013 IO which are somewhat depending on the version and vendor
1014 of the C compiler. Using our own "crlf" layer as the buffer
1015 avoids those issues and makes things more uniform. The
1016 "crlf" layer provides CRLF conversion as well as buffering.
1017
1018 This release (5.14) uses "unix" as the bottom layer on
1019 Win32, and so still uses the C compiler's numeric file
1020 descriptor routines. There is an experimental native
1021 "win32" layer, which is expected to be enhanced and should
1022 eventually become the default under Win32.
1023
1024 The PERLIO environment variable is completely ignored when
1025 Perl is run in taint mode.
1026
1027 PERLIO_DEBUG
1028 If set to the name of a file or device when Perl is run
1029 with the -Di command-line switch, the logging of certain
1030 operations of the PerlIO subsystem will be redirected to
1031 the specified file rather than going to stderr, which is
1032 the default. The file is opened in append mode. Typical
1033 uses are in Unix:
1034
1035 % env PERLIO_DEBUG=/tmp/perlio.log perl -Di script ...
1036
1037 and under Win32, the approximately equivalent:
1038
1039 > set PERLIO_DEBUG=CON
1040 perl -Di script ...
1041
1042 This functionality is disabled for setuid scripts, for
1043 scripts run with -T, and for scripts run on a Perl built
1044 without "-DDEBUGGING" support.
1045
1046 PERLLIB A list of directories in which to look for Perl library
1047 files before looking in the standard library. If PERL5LIB
1048 is defined, PERLLIB is not used.
1049
1050 The PERLLIB environment variable is completely ignored when
1051 Perl is run in taint mode.
1052
1053 PERL5DB The command used to load the debugger code. The default
1054 is:
1055
1056 BEGIN { require "perl5db.pl" }
1057
1058 The PERL5DB environment variable is only used when Perl is
1059 started with a bare -d switch.
1060
1061 PERL5DB_THREADED
1062 If set to a true value, indicates to the debugger that the
1063 code being debugged uses threads.
1064
1065 PERL5SHELL (specific to the Win32 port)
1066 On Win32 ports only, may be set to an alternative shell
1067 that Perl must use internally for executing "backtick"
1068 commands or system(). Default is "cmd.exe /x/d/c" on
1069 WindowsNT and "command.com /c" on Windows95. The value is
1070 considered space-separated. Precede any character that
1071 needs to be protected, like a space or backslash, with
1072 another backslash.
1073
1074 Note that Perl doesn't use COMSPEC for this purpose because
1075 COMSPEC has a high degree of variability among users,
1076 leading to portability concerns. Besides, Perl can use a
1077 shell that may not be fit for interactive use, and setting
1078 COMSPEC to such a shell may interfere with the proper
1079 functioning of other programs (which usually look in
1080 COMSPEC to find a shell fit for interactive use).
1081
1082 Before Perl 5.10.0 and 5.8.8, PERL5SHELL was not taint
1083 checked when running external commands. It is recommended
1084 that you explicitly set (or delete) $ENV{PERL5SHELL} when
1085 running in taint mode under Windows.
1086
1087 PERL_ALLOW_NON_IFS_LSP (specific to the Win32 port)
1088 Set to 1 to allow the use of non-IFS compatible LSPs
1089 (Layered Service Providers). Perl normally searches for an
1090 IFS-compatible LSP because this is required for its
1091 emulation of Windows sockets as real filehandles. However,
1092 this may cause problems if you have a firewall such as
1093 McAfee Guardian, which requires that all applications use
1094 its LSP but which is not IFS-compatible, because clearly
1095 Perl will normally avoid using such an LSP.
1096
1097 Setting this environment variable to 1 means that Perl will
1098 simply use the first suitable LSP enumerated in the
1099 catalog, which keeps McAfee Guardian happy--and in that
1100 particular case Perl still works too because McAfee
1101 Guardian's LSP actually plays other games which allow
1102 applications requiring IFS compatibility to work.
1103
1104 PERL_DEBUG_MSTATS
1105 Relevant only if Perl is compiled with the "malloc"
1106 included with the Perl distribution; that is, if "perl
1107 -V:d_mymalloc" is "define".
1108
1109 If set, this dumps out memory statistics after execution.
1110 If set to an integer greater than one, also dumps out
1111 memory statistics after compilation.
1112
1113 PERL_DESTRUCT_LEVEL
1114 Relevant only if your Perl executable was built with
1115 -DDEBUGGING, this controls the behaviour of global
1116 destruction of objects and other references. See
1117 "PERL_DESTRUCT_LEVEL" in perlhacktips for more information.
1118
1119 PERL_DL_NONLAZY
1120 Set to "1" to have Perl resolve all undefined symbols when
1121 it loads a dynamic library. The default behaviour is to
1122 resolve symbols when they are used. Setting this variable
1123 is useful during testing of extensions, as it ensures that
1124 you get an error on misspelled function names even if the
1125 test suite doesn't call them.
1126
1127 PERL_ENCODING
1128 If using the "use encoding" pragma without an explicit
1129 encoding name, the PERL_ENCODING environment variable is
1130 consulted for an encoding name.
1131
1132 PERL_HASH_SEED
1133 (Since Perl 5.8.1, new semantics in Perl 5.18.0) Used to
1134 override the randomization of Perl's internal hash
1135 function. The value is expressed in hexadecimal, and may
1136 include a leading 0x. Truncated patterns are treated as
1137 though they are suffixed with sufficient 0's as required.
1138
1139 If the option is provided, and "PERL_PERTURB_KEYS" is NOT
1140 set, then a value of '0' implies "PERL_PERTURB_KEYS=0" and
1141 any other value implies "PERL_PERTURB_KEYS=2".
1142
1143 PLEASE NOTE: The hash seed is sensitive information. Hashes
1144 are randomized to protect against local and remote attacks
1145 against Perl code. By manually setting a seed, this
1146 protection may be partially or completely lost.
1147
1148 See "Algorithmic Complexity Attacks" in perlsec,
1149 "PERL_PERTURB_KEYS", and "PERL_HASH_SEED_DEBUG" for more
1150 information.
1151
1152 PERL_PERTURB_KEYS
1153 (Since Perl 5.18.0) Set to "0" or "NO" then traversing
1154 keys will be repeatable from run to run for the same
1155 PERL_HASH_SEED. Insertion into a hash will not change the
1156 order, except to provide for more space in the hash. When
1157 combined with setting PERL_HASH_SEED this mode is as close
1158 to pre 5.18 behavior as you can get.
1159
1160 When set to "1" or "RANDOM" then traversing keys will be
1161 randomized. Every time a hash is inserted into the key
1162 order will change in a random fashion. The order may not be
1163 repeatable in a following program run even if the
1164 PERL_HASH_SEED has been specified. This is the default mode
1165 for perl.
1166
1167 When set to "2" or "DETERMINISTIC" then inserting keys into
1168 a hash will cause the key order to change, but in a way
1169 that is repeatable from program run to program run.
1170
1171 NOTE: Use of this option is considered insecure, and is
1172 intended only for debugging non-deterministic behavior in
1173 Perl's hash function. Do not use it in production.
1174
1175 See "Algorithmic Complexity Attacks" in perlsec and
1176 "PERL_HASH_SEED" and "PERL_HASH_SEED_DEBUG" for more
1177 information. You can get and set the key traversal mask for
1178 a specific hash by using the "hash_traversal_mask()"
1179 function from Hash::Util.
1180
1181 PERL_HASH_SEED_DEBUG
1182 (Since Perl 5.8.1.) Set to "1" to display (to STDERR)
1183 information about the hash function, seed, and what type of
1184 key traversal randomization is in effect at the beginning
1185 of execution. This, combined with "PERL_HASH_SEED" and
1186 "PERL_PERTURB_KEYS" is intended to aid in debugging
1187 nondeterministic behaviour caused by hash randomization.
1188
1189 Note that any information about the hash function,
1190 especially the hash seed is sensitive information: by
1191 knowing it, one can craft a denial-of-service attack
1192 against Perl code, even remotely; see "Algorithmic
1193 Complexity Attacks" in perlsec for more information. Do not
1194 disclose the hash seed to people who don't need to know it.
1195 See also "hash_seed()" and "key_traversal_mask()" in
1196 Hash::Util.
1197
1198 An example output might be:
1199
1200 HASH_FUNCTION = ONE_AT_A_TIME_HARD HASH_SEED = 0x652e9b9349a7a032 PERTURB_KEYS = 1 (RANDOM)
1201
1202 PERL_MEM_LOG
1203 If your Perl was configured with -Accflags=-DPERL_MEM_LOG,
1204 setting the environment variable "PERL_MEM_LOG" enables
1205 logging debug messages. The value has the form
1206 "<number>[m][s][t]", where "number" is the file descriptor
1207 number you want to write to (2 is default), and the
1208 combination of letters specifies that you want information
1209 about (m)emory and/or (s)v, optionally with (t)imestamps.
1210 For example, "PERL_MEM_LOG=1mst" logs all information to
1211 stdout. You can write to other opened file descriptors in a
1212 variety of ways:
1213
1214 $ 3>foo3 PERL_MEM_LOG=3m perl ...
1215
1216 PERL_ROOT (specific to the VMS port)
1217 A translation-concealed rooted logical name that contains
1218 Perl and the logical device for the @INC path on VMS only.
1219 Other logical names that affect Perl on VMS include
1220 PERLSHR, PERL_ENV_TABLES, and SYS$TIMEZONE_DIFFERENTIAL,
1221 but are optional and discussed further in perlvms and in
1222 README.vms in the Perl source distribution.
1223
1224 PERL_SIGNALS
1225 Available in Perls 5.8.1 and later. If set to "unsafe",
1226 the pre-Perl-5.8.0 signal behaviour (which is immediate but
1227 unsafe) is restored. If set to "safe", then safe (but
1228 deferred) signals are used. See "Deferred Signals (Safe
1229 Signals)" in perlipc.
1230
1231 PERL_UNICODE
1232 Equivalent to the -C command-line switch. Note that this
1233 is not a boolean variable. Setting this to "1" is not the
1234 right way to "enable Unicode" (whatever that would mean).
1235 You can use "0" to "disable Unicode", though (or
1236 alternatively unset PERL_UNICODE in your shell before
1237 starting Perl). See the description of the -C switch for
1238 more information.
1239
1240 PERL_USE_UNSAFE_INC
1241 If perl has been configured to not have the current
1242 directory in @INC by default, this variable can be set to
1243 "1" to reinstate it. It's primarily intended for use while
1244 building and testing modules that have not been updated to
1245 deal with "." not being in @INC and should not be set in
1246 the environment for day-to-day use.
1247
1248 SYS$LOGIN (specific to the VMS port)
1249 Used if chdir has no argument and HOME and LOGDIR are not
1250 set.
1251
1252 PERL_INTERNAL_RAND_SEED
1253 Set to a non-negative integer to seed the random number
1254 generator used internally by perl for a variety of
1255 purposes.
1256
1257 Ignored if perl is run setuid or setgid. Used only for
1258 some limited startup randomization (hash keys) if "-T" or
1259 "-t" perl is started with tainting enabled.
1260
1261 Perl may be built to ignore this variable.
1262
1263 Perl also has environment variables that control how Perl handles data
1264 specific to particular natural languages; see perllocale.
1265
1266 Perl and its various modules and components, including its test
1267 frameworks, may sometimes make use of certain other environment
1268 variables. Some of these are specific to a particular platform.
1269 Please consult the appropriate module documentation and any
1270 documentation for your platform (like perlsolaris, perllinux,
1271 perlmacosx, perlwin32, etc) for variables peculiar to those specific
1272 situations.
1273
1274 Perl makes all environment variables available to the program being
1275 executed, and passes these along to any child processes it starts.
1276 However, programs running setuid would do well to execute the following
1277 lines before doing anything else, just to keep people honest:
1278
1279 $ENV{PATH} = "/bin:/usr/bin"; # or whatever you need
1280 $ENV{SHELL} = "/bin/sh" if exists $ENV{SHELL};
1281 delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
1282
1283
1284
1285perl v5.28.2 2018-11-01 PERLRUN(1)