Table A.18. Command-Line Switches
Switch | Description |
---|
-0 | Specify a record separator. |
-a | Turns 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";
|
-c | Checks Perl syntax without executing script. |
-d | Turns on Perl debugger for script. |
-D | Sets Perl debugging flags. (Check your Perl installation to make sure debugging was installed.) To watch how Perl executes a script, use -D14. |
-e command | Used to execute Perl commands at the command line rather than in a script. |
-Fpattern | Specifies 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. |
-h | Prints a summary of Perl's command-line options. |
-iextension | Enables 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. |
-Idirectory | Used 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. |
-ldigits | Enables 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]... | |
-mmodule | Executes the use module before executing the Perl script. |
-Mmodule | Executes 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. |
-n | Causes Perl to implicitly loop over a named file, printing only lines specified. |
-p | Causes Perl to implicitly loop over a named file, printing all lines in addition to those specified. |
-P | Causes script to be run through the C preprocessor before being compiled by Perl. |
-s | Enables 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. |
-S | Makes Perl use the PATH environment variable to search for the script if the #!/usr/bin/perl line is not supported. |
-T | Forces "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. |
-u | Causes a core dump of script after compilation (UNIX based). |
-U | Allows Perl to do unsafe operations; e.g., unlinking directories if superuser. |
-v | Prints Perl version information (UNIX based). |
-V | Prints a summary of the most important Perl configuration values and the current value of the @INC array. |
-V:NAME | Prints the value of NAME, where NAME is a configuration variable. |
-w | Prints warnings about possible misuse of reserved words, filehandles, subroutines, etc. |
-W | Enables all warnings even if disabled locally using no warnings. |
-xdirectory | Any 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. |
-X | Disables all warnings. |