Perl Cheat Sheet Page 3

ADVERTISEMENT

1. Command line options
turns on autosplit mode when used with -n or -p . Splits to @F .
-a
checks syntax but does not execute. It does run BEGIN and END blocks.
-c
-d [ :
]
DEBUGGER
runs the script under the debugger. Use ‘ -de 0 ’ to start the debugger
without a script.
NUMBER
-D
sets debugging flags.
-e
COMMANDLINE
may be used to enter a single line of script. Multiple -e commands may
be given to build up a multi-line script.
-F
REGEXP
specifies a regular expression to split on if -a is in effect.
prints the Perl usage summary. Does not execute.
-h
-i
EXT
files processed by the < > construct are to be edited in-place.
with -P : tells the C preprocessor where to look for include files. The
-I
DIR
directory is prepended to @INC .
-l [
OCTNUM
]
enables automatic line ending processing, e.g. -l013 .
MODULE
-m
imports the
before executing the script.
may be
MODULE
MODULE
followed by a ‘ = ’ and a comma-separated list of items.
MODULE
-M
Same as -m , but with more trickery.
assumes an input loop around the script. Lines are not printed.
-n
assumes an input loop around the script. Lines are printed.
-p
runs the C preprocessor on the script before compilation by Perl.
-P
interprets ‘ -xxx ’ on the command line as a switch and sets the
-s
corresponding variable $xxx in the script.
uses the PATH environment variable to search for the script.
-S
turns on taint checking.
-T
dumps core after compiling the script. To be used with the undump
-u
program (where available).
allows Perl to perform unsafe operations.
-U
prints the version and patchlevel of your Perl executable.
-v
-V [ :
VAR
]
prints Perl configuration information.
prints warnings about possible spelling errors and other error-prone
-w
constructs in the script.
-x [
DIR
]
extracts Perl program from the input stream. If
DIR
is specified, switches
to this directory before running the program.
-0 [
]
VAL
(that’s the number zero) designates an initial value for the record
separator $/ . See also -l .
Command line options may be specified on the ‘ #! ’ line of the perl script, except
for -M , -m and -T .
3

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education