Previous Page Next Page

A.5. Command-Line Switches

Table A.18. Command-Line Switches
SwitchDescription
-0Specify a record separator.
-aTurns on autosplit mode when used with -n or -p, performing implicit split on whitespace. Fields are put in @F array.
date | perl -ane 'print "$F[0]\n";

-cChecks Perl syntax without executing script.
-dTurns on Perl debugger for script.
-DSets Perl debugging flags. (Check your Perl installation to make sure debugging was installed.) To watch how Perl executes a script, use -D14.
-e commandUsed to execute Perl commands at the command line rather than in a script.
-FpatternSpecifies a pattern to use when splitting the input line. The pattern is just a regular expression enclosed in slashes or single or double quotes. For example, -F/:+/ splits the input line on one or more colons. Turned on if -a is also in effect.
-hPrints a summary of Perl's command-line options.
-iextensionEnables in-place editing when using <> to loop through a file. If extension is not specified, modifies the file in place. Otherwise, renames the input file with the extension (used as a backup) and creates an output file with the original filename, which is edited in place. This is the selected filehandle for all print statements.
-IdirectoryUsed with -P to tell the C preprocessor where to look for included files, by default /usr/include and /usr/lib/perl and the current directory.
-ldigitsEnables automatic line-ending processing. Chops the line terminator if -n or -p are used. Assigns $\ the value of digits (octal) to add the line terminator back on to print statements. Without digits specified, sets $\ to the current value of $/. (See Table A.2, "Filehandles.")
-m[-]module 
-M[-]module 
-M[-]'module' 
-[mM]module=arg[,arg]... 
-mmoduleExecutes the use module before executing the Perl script.
-MmoduleExecutes the use module before executing the Perl script. Quotes are used if extra text is added. The dash shown in square brackets means that the use directive will be replaced with no.
-nCauses Perl to implicitly loop over a named file, printing only lines specified.
-pCauses Perl to implicitly loop over a named file, printing all lines in addition to those specified.
-PCauses script to be run through the C preprocessor before being compiled by Perl.
-sEnables switch parsing after the script name but before filename arguments, removing any switches found there from the @ARGV array. Sets the switch names to a scalar variable of the same name and assigns 1 to the scalar; e.g., -abc becomes $abc in the script.
-SMakes Perl use the PATH environment variable to search for the script if the #!/usr/bin/perl line is not supported.
-TForces "taint" checks to be turned on for testing a script, which is ordinarily done only on setuid or setgid programs. Recommended for testing CGI scripts.
-uCauses a core dump of script after compilation (UNIX based).
-UAllows Perl to do unsafe operations; e.g., unlinking directories if superuser.
-vPrints Perl version information (UNIX based).
-VPrints a summary of the most important Perl configuration values and the current value of the @INC array.
-V:NAMEPrints the value of NAME, where NAME is a configuration variable.
-wPrints warnings about possible misuse of reserved words, filehandles, subroutines, etc.
-WEnables all warnings even if disabled locally using no warnings.
-xdirectoryAny text preceding the #!/usr/bin/perl line will be ignored. If a directory name is provided as an argument to the -x switch, Perl will change to that directory before execution of the script starts.
-XDisables all warnings.


Previous Page Next Page