home *** CD-ROM | disk | FTP | other *** search
/ Acorn User 10 / AU_CD10.iso / Updates / Perl / Non-RPC / Docs / perlrun < prev    next >
Text File  |  1999-04-17  |  31KB  |  748 lines

  1. NAME
  2.     perlrun - how to execute the Perl interpreter
  3.  
  4. SYNOPSIS
  5.     perl [ -sTuU ] [ -hv ] [ -V[:*configvar*] ] [ -cw ] [
  6.     -d[:*debugger*] ] [ -D[*number/list*] ] [ -pna ] [ -F*pattern* ]
  7.     [ -l[*octal*] ] [ -0[*octal*] ] [ -I*dir* ] [ -m[-]*module* ] [
  8.     -M[-]*'module...'* ] [ -P ] [ -S ] [ -x[*dir*] ] [
  9.     -i[*extension*] ] [ -e *'command'* ] [ -- ] [ *programfile* ] [
  10.     *argument* ]...
  11.  
  12. DESCRIPTION
  13.     Upon startup, Perl looks for your script in one of the following
  14.     places:
  15.  
  16.     1.  Specified line by line via -e switches on the command line.
  17.  
  18.     2.  Contained in the file specified by the first filename on the
  19.         command line. (Note that systems supporting the #! notation
  20.         invoke interpreters this way. See the Location of Perl
  21.         manpage.)
  22.  
  23.     3.  Passed in implicitly via standard input. This works only if
  24.         there are no filename arguments--to pass arguments to a
  25.         STDIN script you must explicitly specify a "-" for the
  26.         script name.
  27.  
  28.  
  29.     With methods 2 and 3, Perl starts parsing the input file from
  30.     the beginning, unless you've specified a -x switch, in which
  31.     case it scans for the first line starting with #! and containing
  32.     the word "perl", and starts there instead. This is useful for
  33.     running a script embedded in a larger message. (In this case you
  34.     would indicate the end of the script using the `__END__' token.)
  35.  
  36.     The #! line is always examined for switches as the line is being
  37.     parsed. Thus, if you're on a machine that allows only one
  38.     argument with the #! line, or worse, doesn't even recognize the
  39.     #! line, you still can get consistent switch behavior regardless
  40.     of how Perl was invoked, even if -x was used to find the
  41.     beginning of the script.
  42.  
  43.     Because many operating systems silently chop off kernel
  44.     interpretation of the #! line after 32 characters, some switches
  45.     may be passed in on the command line, and some may not; you
  46.     could even get a "-" without its letter, if you're not careful.
  47.     You probably want to make sure that all your switches fall
  48.     either before or after that 32 character boundary. Most switches
  49.     don't actually care if they're processed redundantly, but
  50.     getting a - instead of a complete switch could cause Perl to try
  51.     to execute standard input instead of your script. And a partial
  52.     -I switch could also cause odd results.
  53.  
  54.     Some switches do care if they are processed twice, for instance
  55.     combinations of -l and -0. Either put all the switches after the
  56.     32 character boundary (if applicable), or replace the use of -
  57.     0*digits* by `BEGIN{ $/ = "\0digits"; }'.
  58.  
  59.     Parsing of the #! switches starts wherever "perl" is mentioned
  60.     in the line. The sequences "-*" and "- " are specifically
  61.     ignored so that you could, if you were so inclined, say
  62.  
  63.         #!/bin/sh -- # -*- perl -*- -p
  64.         eval 'exec /usr/bin/perl -wS $0 ${1+"$@"}'
  65.             if $running_under_some_shell;
  66.  
  67.  
  68.     to let Perl see the -p switch.
  69.  
  70.     If the #! line does not contain the word "perl", the program
  71.     named after the #! is executed instead of the Perl interpreter.
  72.     This is slightly bizarre, but it helps people on machines that
  73.     don't do #!, because they can tell a program that their SHELL is
  74.     /usr/bin/perl, and Perl will then dispatch the program to the
  75.     correct interpreter for them.
  76.  
  77.     After locating your script, Perl compiles the entire script to
  78.     an internal form. If there are any compilation errors, execution
  79.     of the script is not attempted. (This is unlike the typical
  80.     shell script, which might run part-way through before finding a
  81.     syntax error.)
  82.  
  83.     If the script is syntactically correct, it is executed. If the
  84.     script runs off the end without hitting an exit() or die()
  85.     operator, an implicit `exit(0)' is provided to indicate
  86.     successful completion.
  87.  
  88.   #! and quoting on non-Unix systems
  89.  
  90.     Unix's #! technique can be simulated on other systems:
  91.  
  92.     OS/2
  93.         Put
  94.  
  95.             extproc perl -S -your_switches
  96.  
  97.  
  98.         as the first line in `*.cmd' file (`-S' due to a bug in
  99.         cmd.exe's `extproc' handling).
  100.  
  101.     MS-DOS
  102.         Create a batch file to run your script, and codify it in
  103.         `ALTERNATIVE_SHEBANG' (see the dosish.h file in the source
  104.         distribution for more information).
  105.  
  106.     Win95/NT
  107.         The Win95/NT installation, when using the Activeware port of
  108.         Perl, will modify the Registry to associate the .pl
  109.         extension with the perl interpreter. If you install another
  110.         port of Perl, including the one in the Win32 directory of
  111.         the Perl distribution, then you'll have to modify the
  112.         Registry yourself. Note that this means you can no longer
  113.         tell the difference between an executable Perl program and a
  114.         Perl library file.
  115.  
  116.     Macintosh
  117.         Macintosh perl scripts will have the appropriate Creator and
  118.         Type, so that double-clicking them will invoke the perl
  119.         application.
  120.  
  121.     VMS Put
  122.  
  123.             $ perl -mysw 'f$env("procedure")' 'p1' 'p2' 'p3' 'p4' 'p5' 'p6' 'p7' 'p8' !
  124.             $ exit++ + ++$status != 0 and $exit = $status = undef;
  125.  
  126.  
  127.         at the top of your script, where `-mysw' are any command
  128.         line switches you want to pass to Perl. You can now invoke
  129.         the script directly, by saying `perl script', or as a DCL
  130.         procedure, by saying `@script' (or implicitly via DCL$PATH
  131.         by just using the name of the script).
  132.  
  133.         This incantation is a bit much to remember, but Perl will
  134.         display it for you if you say `perl "-V:startperl"'.
  135.  
  136.  
  137.     Command-interpreters on non-Unix systems have rather different
  138.     ideas on quoting than Unix shells. You'll need to learn the
  139.     special characters in your command-interpreter (`*', `\' and `"'
  140.     are common) and how to protect whitespace and these characters
  141.     to run one-liners (see `-e' below).
  142.  
  143.     On some systems, you may have to change single-quotes to double
  144.     ones, which you must *NOT* do on Unix or Plan9 systems. You
  145.     might also have 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.         # Macintosh
  156.         print "Hello world\n"
  157.          (then Run "Myscript" or Shift-Command-R)
  158.  
  159.         # VMS
  160.         perl -e "print ""Hello world\n"""
  161.  
  162.  
  163.     The problem is that none of this is reliable: it depends on the
  164.     command and it is entirely possible neither works. If 4DOS was
  165.     the command shell, this would probably work better:
  166.  
  167.         perl -e "print <Ctrl-x>"Hello world\n<Ctrl-x>""
  168.  
  169.  
  170.     CMD.EXE in Windows NT slipped a lot of standard Unix
  171.     functionality in when nobody was looking, but just try to find
  172.     documentation for its quoting rules.
  173.  
  174.     Under the Macintosh, it depends which environment you are using.
  175.     The MacPerl shell, or MPW, is much like Unix shells in its
  176.     support for several quoting variants, except that it makes free
  177.     use of the Macintosh's non-ASCII characters as control
  178.     characters.
  179.  
  180.     There is no general solution to all of this. It's just a mess.
  181.  
  182.   Location of Perl
  183.  
  184.     It may seem obvious to say, but Perl is useful only when users
  185.     can easily find it. When possible, it's good for both
  186.     /usr/bin/perl and /usr/local/bin/perl to be symlinks to the
  187.     actual binary. If that can't be done, system administrators are
  188.     strongly encouraged to put (symlinks to) perl and its
  189.     accompanying utilities, such as perldoc, into a directory
  190.     typically found along a user's PATH, or in another obvious and
  191.     convenient place.
  192.  
  193.     In this documentation, `#!/usr/bin/perl' on the first line of
  194.     the script will stand in for whatever method works on your
  195.     system.
  196.  
  197.   Switches
  198.  
  199.     A single-character switch may be combined with the following
  200.     switch, if any.
  201.  
  202.         #!/usr/bin/perl -spi.bak    # same as -s -p -i.bak
  203.  
  204.  
  205.     Switches include:
  206.  
  207.     -0[*digits*]
  208.          specifies the input record separator (`$/') as an octal
  209.          number. If there are no digits, the null character is the
  210.          separator. Other switches may precede or follow the digits.
  211.          For example, if you have a version of find which can print
  212.          filenames terminated by the null character, you can say
  213.          this:
  214.  
  215.              find . -name '*.bak' -print0 | perl -n0e unlink
  216.  
  217.  
  218.          The special value 00 will cause Perl to slurp files in
  219.          paragraph mode. The value 0777 will cause Perl to slurp
  220.          files whole because there is no legal character with that
  221.          value.
  222.  
  223.     -a   turns on autosplit mode when used with a -n or -p. An implicit
  224.          split command to the @F array is done as the first thing
  225.          inside the implicit while loop produced by the -n or -p.
  226.  
  227.              perl -ane 'print pop(@F), "\n";'
  228.  
  229.  
  230.          is equivalent to
  231.  
  232.              while (<>) {
  233.              @F = split(' ');
  234.              print pop(@F), "\n";
  235.              }
  236.  
  237.  
  238.          An alternate delimiter may be specified using -F.
  239.  
  240.     -c   causes Perl to check the syntax of the script and then exit
  241.          without executing it. Actually, it *will* execute `BEGIN',
  242.          `END', and `use' blocks, because these are considered as
  243.          occurring outside the execution of your program.
  244.  
  245.     -d   runs the script under the Perl debugger. See the perldebug
  246.          manpage.
  247.  
  248.     -d:*foo*
  249.          runs the script under the control of a debugging or tracing
  250.          module installed as Devel::foo. E.g., -d:DProf executes the
  251.          script using the Devel::DProf profiler. See the perldebug
  252.          manpage.
  253.  
  254.     -D*letters*
  255.  
  256.     -D*number*
  257.          sets debugging flags. To watch how it executes your script,
  258.          use -Dtls. (This works only if debugging is compiled into
  259.          your Perl.) Another nice value is -Dx, which lists your
  260.          compiled syntax tree. And -Dr displays compiled regular
  261.          expressions. As an alternative, specify a number instead of
  262.          list of letters (e.g., -D14 is equivalent to -Dtls):
  263.  
  264.                  1  p  Tokenizing and parsing
  265.                  2  s  Stack snapshots
  266.                  4  l  Context (loop) stack processing
  267.                  8  t  Trace execution
  268.                 16  o  Method and overloading resolution
  269.                 32  c  String/numeric conversions
  270.                 64  P  Print preprocessor command for -P
  271.                128  m  Memory allocation
  272.                256  f  Format processing
  273.                512  r  Regular expression parsing and execution
  274.               1024  x  Syntax tree dump
  275.               2048  u  Tainting checks
  276.               4096  L  Memory leaks (needs C<-DLEAKTEST> when compiling Perl)
  277.               8192  H  Hash dump -- usurps values()
  278.              16384  X  Scratchpad allocation
  279.              32768  D  Cleaning up
  280.              65536  S  Thread synchronization
  281.  
  282.  
  283.          All these flags require `-DDEBUGGING' when you compile the
  284.          Perl executable. This flag is automatically set if you
  285.          include `-g' option when `Configure' asks you about
  286.          optimizer/debugger flags.
  287.  
  288.     -e *commandline*
  289.          may be used to enter one line of script. If -e is given,
  290.          Perl will not look for a script filename in the argument
  291.          list. Multiple -e commands may be given to build up a
  292.          multi-line script. Make sure to use semicolons where you
  293.          would in a normal program.
  294.  
  295.     -F*pattern*
  296.          specifies the pattern to split on if -a is also in effect.
  297.          The pattern may be surrounded by `//', `""', or `''',
  298.          otherwise it will be put in single quotes.
  299.  
  300.     -h   prints a summary of the options.
  301.  
  302.     -i[*extension*]
  303.          specifies that files processed by the `<>' construct are to
  304.          be edited in-place. It does this by renaming the input
  305.          file, opening the output file by the original name, and
  306.          selecting that output file as the default for print()
  307.          statements. The extension, if supplied, is used to modify
  308.          the name of the old file to make a backup copy, following
  309.          these rules:
  310.  
  311.          If no extension is supplied, no backup is made and the
  312.          current file is overwritten.
  313.  
  314.          If the extension doesn't contain a `*' then it is appended
  315.          to the end of the current filename as a suffix.
  316.  
  317.          If the extension does contain one or more `*' characters,
  318.          then each `*' is replaced with the current filename. In
  319.          perl terms you could think of this as:
  320.  
  321.              ($backup = $extension) =~ s/\*/$file_name/g;
  322.  
  323.  
  324.          This allows you to add a prefix to the backup file, instead
  325.          of (or in addition to) a suffix:
  326.  
  327.              $ perl -pi'bak_*' -e 's/bar/baz/' fileA    # backup to 'bak_fileA'
  328.  
  329.  
  330.          Or even to place backup copies of the original files into
  331.          another directory (provided the directory already exists):
  332.  
  333.              $ perl -pi'old/*.bak' -e 's/bar/baz/' fileA # backup to 'old/fileA.bak'
  334.  
  335.  
  336.          These sets of one-liners are equivalent:
  337.  
  338.              $ perl -pi -e 's/bar/baz/' fileA        # overwrite current file
  339.              $ perl -pi'*' -e 's/bar/baz/' fileA        # overwrite current file
  340.  
  341.              $ perl -pi'.bak' -e 's/bar/baz/' fileA    # backup to 'fileA.bak'
  342.              $ perl -pi'*.bak' -e 's/bar/baz/' fileA    # backup to 'fileA.bak'
  343.  
  344.  
  345.          From the shell, saying
  346.  
  347.              $ perl -p -i.bak -e "s/foo/bar/; ... "
  348.  
  349.  
  350.          is the same as using the script:
  351.  
  352.              #!/usr/bin/perl -pi.bak
  353.              s/foo/bar/;
  354.  
  355.  
  356.          which is equivalent to
  357.  
  358.              #!/usr/bin/perl
  359.              $extension = '.bak';
  360.              while (<>) {
  361.              if ($ARGV ne $oldargv) {
  362.                  if ($extension !~ /\*/) {
  363.                  $backup = $ARGV . $extension;
  364.                  }
  365.                  else {
  366.                  ($backup = $extension) =~ s/\*/$ARGV/g;
  367.                  }
  368.                  rename($ARGV, $backup);
  369.                  open(ARGVOUT, ">$ARGV");
  370.                  select(ARGVOUT);
  371.                  $oldargv = $ARGV;
  372.              }
  373.              s/foo/bar/;
  374.              }
  375.              continue {
  376.              print;    # this prints to original filename
  377.              }
  378.              select(STDOUT);
  379.  
  380.  
  381.          except that the -i form doesn't need to compare $ARGV to
  382.          $oldargv to know when the filename has changed. It does,
  383.          however, use ARGVOUT for the selected filehandle. Note that
  384.          STDOUT is restored as the default output filehandle after
  385.          the loop.
  386.  
  387.          As shown above, Perl creates the backup file whether or not
  388.          any output is actually changed. So this is just a fancy way
  389.          to copy files:
  390.  
  391.              $ perl -p -i'/some/file/path/*' -e 1 file1 file2 file3...
  392.            or
  393.              $ perl -p -i'.bak' -e 1 file1 file2 file3...
  394.  
  395.  
  396.          You can use `eof' without parentheses to locate the end of
  397.          each input file, in case you want to append to each file,
  398.          or reset line numbering (see example in the "eof" entry in
  399.          the perlfunc manpage).
  400.  
  401.          If, for a given file, Perl is unable to create the backup
  402.          file as specified in the extension then it will skip that
  403.          file and continue on with the next one (if it exists).
  404.  
  405.          For a discussion of issues surrounding file permissions and
  406.          `-i', see the "Why does Perl let me delete read-only files?
  407.          Why does -i clobber protected files? Isn't this a bug in
  408.          Perl?" entry in the perlfaq5 manpage.
  409.  
  410.          You cannot use -i to create directories or to strip
  411.          extensions from files.
  412.  
  413.          Perl does not expand `~', so don't do that.
  414.  
  415.          Finally, note that the -i switch does not impede execution
  416.          when no files are given on the command line. In this case,
  417.          no backup is made (the original file cannot, of course, be
  418.          determined) and processing proceeds from STDIN to STDOUT as
  419.          might be expected.
  420.  
  421.     -I*directory*
  422.          Directories specified by -I are prepended to the search
  423.          path for modules (`@INC'), and also tells the C
  424.          preprocessor where to search for include files. The C
  425.          preprocessor is invoked with -P; by default it searches
  426.          /usr/include and /usr/lib/perl.
  427.  
  428.     -l[*octnum*]
  429.          enables automatic line-ending processing. It has two
  430.          effects: first, it automatically chomps "`$/'" (the input
  431.          record separator) when used with -n or -p, and second, it
  432.          assigns "`$\'" (the output record separator) to have the
  433.          value of *octnum* so that any print statements will have
  434.          that separator added back on. If *octnum* is omitted, sets
  435.          "`$\'" to the current value of "`$/'". For instance, to
  436.          trim lines to 80 columns:
  437.  
  438.              perl -lpe 'substr($_, 80) = ""'
  439.  
  440.  
  441.          Note that the assignment `$\ = $/' is done when the switch
  442.          is processed, so the input record separator can be
  443.          different than the output record separator if the -l switch
  444.          is followed by a -0 switch:
  445.  
  446.              gnufind / -print0 | perl -ln0e 'print "found $_" if -p'
  447.  
  448.  
  449.          This sets `$\' to newline and then sets `$/' to the null
  450.          character.
  451.  
  452.     -m[-]*module*
  453.  
  454.     -M[-]*module*
  455.  
  456.     -M[-]*'module ...'*
  457.  
  458.     -[mM][-]*module=arg[,arg]...*
  459.          `-m'*module* executes `use' *module* `();' before executing
  460.          your script.
  461.  
  462.          `-M'*module* executes `use' *module* `;' before executing
  463.          your script. You can use quotes to add extra code after the
  464.          module name, e.g., `-M'module qw(foo bar)''.
  465.  
  466.          If the first character after the `-M' or `-m' is a dash (`-
  467.          ') then the 'use' is replaced with 'no'.
  468.  
  469.          A little builtin syntactic sugar means you can also say `-
  470.          mmodule=foo,bar' or `-Mmodule=foo,bar' as a shortcut for `-
  471.          M'module qw(foo bar)''. This avoids the need to use quotes
  472.          when importing symbols. The actual code generated by `-
  473.          Mmodule=foo,bar' is `use module split(/,/,q{foo,bar})'.
  474.          Note that the `=' form removes the distinction between `-m'
  475.          and `-M'.
  476.  
  477.     -n   causes Perl to assume the following loop around your script,
  478.          which makes it iterate over filename arguments somewhat
  479.          like sed -n or awk:
  480.  
  481.              while (<>) {
  482.              ...        # your script goes here
  483.              }
  484.  
  485.  
  486.          Note that the lines are not printed by default. See -p to
  487.          have lines printed. If a file named by an argument cannot
  488.          be opened for some reason, Perl warns you about it, and
  489.          moves on to the next file.
  490.  
  491.          Here is an efficient way to delete all files older than a
  492.          week:
  493.  
  494.              find . -mtime +7 -print | perl -nle 'unlink;'
  495.  
  496.  
  497.          This is faster than using the `-exec' switch of find
  498.          because you don't have to start a process on every filename
  499.          found.
  500.  
  501.          `BEGIN' and `END' blocks may be used to capture control
  502.          before or after the implicit loop, just as in awk.
  503.  
  504.     -p   causes Perl to assume the following loop around your script,
  505.          which makes it iterate over filename arguments somewhat
  506.          like sed:
  507.  
  508.              while (<>) {
  509.              ...        # your script goes here
  510.              } continue {
  511.              print or die "-p destination: $!\n";
  512.              }
  513.  
  514.  
  515.          If a file named by an argument cannot be opened for some
  516.          reason, Perl warns you about it, and moves on to the next
  517.          file. Note that the lines are printed automatically. An
  518.          error occurring during printing is treated as fatal. To
  519.          suppress printing use the -n switch. A -p overrides a -n
  520.          switch.
  521.  
  522.          `BEGIN' and `END' blocks may be used to capture control
  523.          before or after the implicit loop, just as in awk.
  524.  
  525.     -P   causes your script to be run through the C preprocessor before
  526.          compilation by Perl. (Because both comments and cpp
  527.          directives begin with the # character, you should avoid
  528.          starting comments with any words recognized by the C
  529.          preprocessor such as "if", "else", or "define".)
  530.  
  531.     -s   enables some rudimentary switch parsing for switches on the
  532.          command line after the script name but before any filename
  533.          arguments (or before a --). Any switch found there is
  534.          removed from @ARGV and sets the corresponding variable in
  535.          the Perl script. The following script prints "true" if and
  536.          only if the script is invoked with a -xyz switch.
  537.  
  538.              #!/usr/bin/perl -s
  539.              if ($xyz) { print "true\n"; }
  540.  
  541.  
  542.     -S   makes Perl use the PATH environment variable to search for the
  543.          script (unless the name of the script contains directory
  544.          separators). On some platforms, this also makes Perl append
  545.          suffixes to the filename while searching for it. For
  546.          example, on Win32 platforms, the ".bat" and ".cmd" suffixes
  547.          are appended if a lookup for the original name fails, and
  548.          if the name does not already end in one of those suffixes.
  549.          If your Perl was compiled with DEBUGGING turned on, using
  550.          the -Dp switch to Perl shows how the search progresses.
  551.  
  552.          If the filename supplied contains directory separators
  553.          (i.e. it is an absolute or relative pathname), and if the
  554.          file is not found, platforms that append file extensions
  555.          will do so and try to look for the file with those
  556.          extensions added, one by one.
  557.  
  558.          On DOS-like platforms, if the script does not contain
  559.          directory separators, it will first be searched for in the
  560.          current directory before being searched for on the PATH. On
  561.          Unix platforms, the script will be searched for strictly on
  562.          the PATH.
  563.  
  564.          Typically this is used to emulate #! startup on platforms
  565.          that don't support #!. This example works on many platforms
  566.          that have a shell compatible with Bourne shell:
  567.  
  568.              #!/usr/bin/perl
  569.              eval 'exec /usr/bin/perl -wS $0 ${1+"$@"}'
  570.                  if $running_under_some_shell;
  571.  
  572.  
  573.          The system ignores the first line and feeds the script to
  574.          /bin/sh, which proceeds to try to execute the Perl script
  575.          as a shell script. The shell executes the second line as a
  576.          normal shell command, and thus starts up the Perl
  577.          interpreter. On some systems $0 doesn't always contain the
  578.          full pathname, so the -S tells Perl to search for the
  579.          script if necessary. After Perl locates the script, it
  580.          parses the lines and ignores them because the variable
  581.          $running_under_some_shell is never true. If the script will
  582.          be interpreted by csh, you will need to replace `${1+"$@"}'
  583.          with `$*', even though that doesn't understand embedded
  584.          spaces (and such) in the argument list. To start up sh
  585.          rather than csh, some systems may have to replace the #!
  586.          line with a line containing just a colon, which will be
  587.          politely ignored by Perl. Other systems can't control that,
  588.          and need a totally devious construct that will work under
  589.          any of csh, sh, or Perl, such as the following:
  590.  
  591.              eval '(exit $?0)' && eval 'exec /usr/bin/perl -wS $0 ${1+"$@"}'
  592.              & eval 'exec /usr/bin/perl -wS $0 $argv:q'
  593.                  if $running_under_some_shell;
  594.  
  595.  
  596.     -T   forces "taint" checks to be turned on so you can test them.
  597.          Ordinarily these checks are done only when running setuid
  598.          or setgid. It's a good idea to turn them on explicitly for
  599.          programs run on another's behalf, such as CGI programs. See
  600.          the perlsec manpage. Note that (for security reasons) this
  601.          option must be seen by Perl quite early; usually this means
  602.          it must appear early on the command line or in the #! line
  603.          (for systems which support that).
  604.  
  605.     -u   causes Perl to dump core after compiling your script. You can
  606.          then in theory take this core dump and turn it into an
  607.          executable file by using the undump program (not supplied).
  608.          This speeds startup at the expense of some disk space
  609.          (which you can minimize by stripping the executable).
  610.          (Still, a "hello world" executable comes out to about 200K
  611.          on my machine.) If you want to execute a portion of your
  612.          script before dumping, use the dump() operator instead.
  613.          Note: availability of undump is platform specific and may
  614.          not be available for a specific port of Perl. It has been
  615.          superseded by the new perl-to-C compiler, which is more
  616.          portable, even though it's still only considered beta.
  617.  
  618.     -U   allows Perl to do unsafe operations. Currently the only
  619.          "unsafe" operations are the unlinking of directories while
  620.          running as superuser, and running setuid programs with
  621.          fatal taint checks turned into warnings. Note that the -w
  622.          switch (or the `$^W' variable) must be used along with this
  623.          option to actually generate the taint-check warnings.
  624.  
  625.     -v   prints the version and patchlevel of your Perl executable.
  626.  
  627.     -V   prints summary of the major perl configuration values and the
  628.          current value of @INC.
  629.  
  630.     -V:*name*
  631.          Prints to STDOUT the value of the named configuration
  632.          variable.
  633.  
  634.     -w   prints warnings about variable names that are mentioned only
  635.          once, and scalar variables that are used before being set.
  636.          Also warns about redefined subroutines, and references to
  637.          undefined filehandles or filehandles opened read-only that
  638.          you are attempting to write on. Also warns you if you use
  639.          values as a number that doesn't look like numbers, using an
  640.          array as though it were a scalar, if your subroutines
  641.          recurse more than 100 deep, and innumerable other things.
  642.  
  643.          You can disable specific warnings using `__WARN__' hooks,
  644.          as described in the perlvar manpage and the "warn" entry in
  645.          the perlfunc manpage. See also the perldiag manpage and the
  646.          perltrap manpage.
  647.  
  648.     -x *directory*
  649.          tells Perl that the script is embedded in a message.
  650.          Leading garbage will be discarded until the first line that
  651.          starts with #! and contains the string "perl". Any
  652.          meaningful switches on that line will be applied. If a
  653.          directory name is specified, Perl will switch to that
  654.          directory before running the script. The -x switch controls
  655.          only the disposal of leading garbage. The script must be
  656.          terminated with `__END__' if there is trailing garbage to
  657.          be ignored (the script can process any or all of the
  658.          trailing garbage via the DATA filehandle if desired).
  659.  
  660.  
  661. ENVIRONMENT
  662.     HOME        Used if chdir has no argument.
  663.  
  664.     LOGDIR      Used if chdir has no argument and HOME is not set.
  665.  
  666.     PATH        Used in executing subprocesses, and in finding the
  667.                 script if -S is used.
  668.  
  669.     PERL5LIB    A colon-separated list of directories in which to look
  670.                 for Perl library files before looking in the
  671.                 standard library and the current directory. If
  672.                 PERL5LIB is not defined, PERLLIB is used. When
  673.                 running taint checks (because the script was running
  674.                 setuid or setgid, or the -T switch was used),
  675.                 neither variable is used. The script should instead
  676.                 say
  677.  
  678.                     use lib "/my/directory";
  679.  
  680.  
  681.     PERL5OPT    Command-line options (switches). Switches in this
  682.                 variable are taken as if they were on every Perl
  683.                 command line. Only the -[DIMUdmw] switches are
  684.                 allowed. When running taint checks (because the
  685.                 script was running setuid or setgid, or the -T
  686.                 switch was used), this variable is ignored. If
  687.                 PERL5OPT begins with -T, tainting will be enabled,
  688.                 and any subsequent options ignored.
  689.  
  690.     PERLLIB     A colon-separated list of directories in which to look
  691.                 for Perl library files before looking in the
  692.                 standard library and the current directory. If
  693.                 PERL5LIB is defined, PERLLIB is not used.
  694.  
  695.     PERL5DB     The command used to load the debugger code. The default
  696.                 is:
  697.  
  698.                     BEGIN { require 'perl5db.pl' }
  699.  
  700.  
  701.     PERL5SHELL (specific to WIN32 port)
  702.                 May be set to an alternative shell that perl must
  703.                 use internally for executing "backtick" commands or
  704.                 system(). Default is `cmd.exe /x/c' on WindowsNT and
  705.                 `command.com /c' on Windows95. The value is
  706.                 considered to be space delimited. Precede any
  707.                 character that needs to be protected (like a space
  708.                 or backslash) with a backslash.
  709.  
  710.                 Note that Perl doesn't use COMSPEC for this purpose
  711.                 because COMSPEC has a high degree of variability
  712.                 among users, leading to portability concerns.
  713.                 Besides, perl can use a shell that may not be fit
  714.                 for interactive use, and setting COMSPEC to such a
  715.                 shell may interfere with the proper functioning of
  716.                 other programs (which usually look in COMSPEC to
  717.                 find a shell fit for interactive use).
  718.  
  719.     PERL_DEBUG_MSTATS
  720.                 Relevant only if perl is compiled with the malloc
  721.                 included with the perl distribution (that is, if
  722.                 `perl -V:d_mymalloc' is 'define'). If set, this
  723.                 causes memory statistics to be dumped after
  724.                 execution. If set to an integer greater than one,
  725.                 also causes memory statistics to be dumped after
  726.                 compilation.
  727.  
  728.     PERL_DESTRUCT_LEVEL
  729.                 Relevant only if your perl executable was built with
  730.                 -DDEBUGGING, this controls the behavior of global
  731.                 destruction of objects and other references.
  732.  
  733.  
  734.     Perl also has environment variables that control how Perl
  735.     handles data specific to particular natural languages. See the
  736.     perllocale manpage.
  737.  
  738.     Apart from these, Perl uses no other environment variables,
  739.     except to make them available to the script being executed, and
  740.     to child processes. However, scripts running setuid would do
  741.     well to execute the following lines before doing anything else,
  742.     just to keep people honest:
  743.  
  744.         $ENV{PATH} = '/bin:/usr/bin';    # or whatever you need
  745.         $ENV{SHELL} = '/bin/sh' if exists $ENV{SHELL};
  746.         delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
  747.  
  748.