Command Line Reference: Switch Function
Command Line Reference: Switch Function
The following is a list of the available switches which can be appended to the calling of perl from the
command line. The exact syntax for calling perl from the command line is as follows:
Switch Function
-0(octal) This sets the record separator ($/) by specifying the character's number
in the ASCII table in octal. For example, if we wanted to set our
separator to the character 'e' we would say perl -0101. The default
is the null character, and $/ is set to this if no argument is given. See
Appendix F for a complete ASCII table.
-a -a can be used in conjunction with -n or -p. It enables autosplit, and
uses whitespace as the default delimiter. Using -p will print out the
results, which are always stored in the array @F.
-C Enables native wide character system interfaces
-c This is a syntactic test only. It stops Perl executing, but reports on any
compilation errors that a program has before it exits. Any other switches
that have a runtime effect on your program will be ignored will -c is
enabled.
-d filename This switch invokes the Perl debugger. The Perl debugger will only run
once you have gotten your program to compile. Enabling -d allows you
to prompt debugging commands such as install breakpoints, and many
others.
Table continued on following page
Appendix E
Switch Function
-D(number) -D will set debugging flags, but only if you have debugging compiled
into your program. The following table shows you the arguments that
you may use for -D, and the resulting meaning of the switch.
-D(list)
Argument
(number)
Argument
(character)
Operation
1
p
Tokenizing and parsing
2
s
Stack snapshots
4
l
Label stack Processing
8
t
Trace execution
16
o
Object method lookup
32
c
String/numeric conversions
580
Command Line Reference
Switch Function
-D(list) (cont.) 64
p
Print preprocessor command for -p
128
m
Memory allocation
256
f
Format processing
512
r
Regular expression processing
1024
x
Syntax tree dump
2048
u
Tainting checks
4096
l
Memory leaks
8192
h
Hash dump
Table continued on following page
581
Appendix E
Switch Function
-D(list) (cont.) 16384
X
Scratchpad allocations
32768
D
Cleaning up
582
Command Line Reference
Switch Function
-s This defines variables with the same name as the switches that follow on
the command line. The other switches are also removed from @ARGV.
The newly defined variables are set to 1 by default. Some parsing of the
other switches is also enabled.
-S Causes perl to look for a given program file using the PATH
environment variable. In other words, it acts much like #!
-T Stops data entering a program from performing unsafe operations. It's a
good idea to use this when there is a lot of information exchange
occuring, like in CGI programming.
-u This will perform a core dump after compiling the program.
-U This forces Perl to allow unsafe operations.
-v Prints the version of Perl that is currently being used (includes VERY
IMPORTANT perl info).
-V(:variable) Prints out a summary of the main configuration values used by Perl
during compiling. It will also print out the value of the @INC array.
-w Invokes the rasiing of many useful warnings based on the (poor or bad)
syntax of the program being run.
This switch has been deprecated in perl 5.6, in favor of the use
warnings pragma.
-W Enables all warnings.
-x(directory) Tells Perl to get rid of extraneous text that precedes the shebang line.
All switches on the shebang line will still be enabled.
-X This will disable all warnings. We already know that we always use use
warnings when writing our programs. So you won't need this.
583
This work is licensed under the Creative Commons Attribution-NoDerivs-NonCommercial License. To view a copy of this
license, visit http://creativecommons.org/licenses/by-nd-nc/1.0 or send a letter to Creative Commons, 559 Nathan Abbott Way,
Stanford, California 94305, USA.
Attribution: The licensor permits others to copy, distribute, display, and perform the work. In return, licensees must give the
original author credit.
No Derivative Works: The licensor permits others to copy, distribute, display and perform only unaltered copies of the work --
not derivative works based on it.
Noncommercial: The licensor permits others to copy, distribute, display, and perform the work. In return, licensees may not
use the work for commercial purposes -- unless they get the licensor's permission.