home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    


perl [options ] [programfile ] [files ]

perl is the interpreter for the Perl programming language (the Swiss Army knife of Unix programming tools). The Perl program is provided via one or more -e options. If no -e options are used, the first file named on the command line is used for the program.

For more information about Perl, see Learning Perl , Programming Perl , and Advanced Perl Programming , all listed in the Bibliography.

Note: while not distributed with SVR4 or Solaris, perl is widely used for the Web, CGI, and system-administration tasks, and many other things. The starting point for All Things Perl is http://www.perl.com .


This option list is for perl Version 5.005 patchlevel 2. See perlrun (1) for more details.


Turn on autosplit mode when used with -n or -p . Splits to @F .


Check syntax but does not execute.


Run the script under the debugger. Use -de 0 to start the debugger without a script.

-d : module

Run the script under control of the module installed as Devel: module .

-D flags

Set debugging flags. flags may be a string of letters, or the sum of their numerical equivalents. See "Debugging Flags." perl must be compiled with -DDEBUGGING for these flags to take effect.

-e ' commandline '

May be used to enter a single line of script. Multiple -e commands may be given to build up a multiline script.

-F regexp

Specify a regular expression to split on if -a is in effect.


Print a summary of the options.

-i [ext ]

Files processed by the <> construct are to be edited in place. The old copy is renamed, and the processed copy is written to the original filename. The optional ext indicates an extension to use for the renamed copy. Various rules apply to how this is done; see perlrun (1).

-I dir

With -P , tells the C preprocessor where to look for include files. The directory is also prepended to @INC .

-l [octnum ]

Enables automatic line-end processing, e.g., -l013 .

-m [- ]module

Equivalent to use module (); . With a - after -m , it is equivalent to no module (); .

-m [- ]' module = arg [,arg ]' , -M [- ]' module = arg [,arg ]' ,

Shorthand for -M'module qw(arg ...)' . This avoids the need for quoting inside the argument.

-M [- ]' module [...]'

Equivalent to use module ...; . With a - after -M , it is equivalent to no module ...; . The "..." represents additional code you might wish to supply, for example:

-M'mymodule qw(whizfunc wimpfunc)'


Assume an input loop around your script. Input lines are not printed. (Like sed -n or awk .)


Assume an input loop around your script. Input lines are printed. (Like sed .)


Run the C preprocessor on the script before compilation by perl .


Interpret - xxx on the command line as a switch and sets the corresponding variable $xxx in the script.


Use the PATH environment variable to search for the script.


Force taint checking.


Dump core after compiling the script. For use with the undump (1) program (where available). Largely superseded by the Perl-to-C compiler that comes with perl .


Allow perl to perform unsafe operations.


Print the version and patchlevel of the perl executable.


Print the configuration information and the value of @INC .

-V : var

Print the value of configuration variable var to standard output.


Print warnings about possible spelling errors and other error-prone constructs in the script.

-x [dir ]

Extract the Perl program from the input stream. If dir is specified, perl switches to it before running the program.

-0 val

(That's the number zero.) Designate an initial value for the record separator $/ . See also -l .

Debugging Flags

Value Letter Debugs
1 p Tokenizing and parsing
2 s Stack snapshots
4 l Context (loop) stack processing
8 t Trace execution
16 o Method and overloading resolution
32 c String/numeric conversions
64 P Print preprocessor command for -P
128 m Memory allocation
256 f Format processing
512 r Regular expression parsing and execution
1024 x Syntax tree dump
2048 u Tainting checks
4096 L

Memory leaks (needs -DLEAKTEST when compiling perl )

8192 H Hash dump; usurps values()
16384 X Scratch-pad allocation
32768 D Cleaning up
65536 S Thread synchronization

Previous: Reference: pax UNIX in a Nutshell: System V Edition Next: Reference: pic
Reference: pax Book Index Reference: pic

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System