DelphiFAQ Home Search:
General :: Programming :: perl
General questions about perl.


This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.
Recommended links on this topic:
Featured Article

perl command line options

Here is a list of switches that you can pass to the perl interpreter:

     Lets you specify the record separator ($/) as an octal number.
     For example, -0055 will cause records to end on a dash. If no 
     number is specified, records will end on null characters. The special 
     value of 00 will place Perl into paragraph mode. And 0777 will force 
     Perl to read the whole file in one shot because 0777 is not a legal 
     character value. 
     This option must be used in conjunction with either the -n or 
     -p option. Using the -a option will automatically feed input lines
     to the split function. The results of the split are placed into
     the @F variable.
     This option lets you check the syntax of your script without
     fully executing it. The BEGIN blocks and use statements are still
     executed because they are needed by the compilation process.
     This option lets you start the Perl debugger.
     This option lets you turn on different behaviors related to
     the debugging process. The following table shows you the sub-options
     that can be used. Please note, however, that not all releases of Perl
     can use this feature. For example, the hip port of Perl for Win32 can't.
     If your version of Perl does not have this option, you will see the
     message "Recompile perl with -DDEBUGGING to use -D switch" when you try
     it. If you want to watch your script as it executes, use -D14. Following
     is a list of the other values that you can use. You can add the numbers
     together to specify more than one behavior (such as 8+4+2 = 14) or
     you can use the letters.
     1 		p 	Tokenizing and Parsing
     2 		s 	Stack Snapshots
     4 		l 	Label Stack Processing
     8 		t 	Trace Execution
     16 		o 	Operator Node Construction
     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
     1024 	x 	Syntax Tree Dump
     2048 	u 	Tainting Checks
     4096 	L 	Memory Leaks (not supported any more)
     8192 	H 	Hash Dump - usurps values()
     16384 	X 	Scratchpad Allocation
     32768 	D 	Cleaning Up
     The option lets you specify a single line of code on the command
     line. This line of code will be executed in lieu of a script file.
     You can use multiple -e options to create a multiple line program-
     although given the probability of a typing mistake, I'd create a
     script file instead. Semi-colons must be used to end Perl statements
     just like a normal script.
     This option modifies the behavior of the -a option. It lets you
     change the regular expression that is used to split the input lines.
     For example, -F /:+/ will split the input line whenever one or more
     colons are found. The slashes are optional; they simply delimit the 
     pattern if they are there. I use them for their aesthetic value.
     This option lets you edit files in-place. It is used in conjunction 
     with the -n or -p option. See "Example: Using the -i option" for more 
     This option is used in conjunction with the -P option. It tells 
     the C preprocessor where to look for include files. The default search 
     directories include /usr/include and /usr/lib/Perl.
     This option turns on line-ending processing. It can be used to set 
     the output line terminator variable ($/) by specifying an octal value.
     This option places a loop around your script. It will automatically
     read a line from the diamond operator and then execute the script. It 
     is most often used with the -e option.
     This option places a loop around your script. It will automatically 
     read a line from the diamond operator, execute the script, and then 
     print $_. It is most often used with the -e option.
     This option will invoke the C preprocessor before compiling your 
     script. This might be useful if you have some C programming experience 
     and would like to use the #include and #define facility. The C 
     preprocessor can also be used for conditional compilation. Use the -I 
     option to tell Perl where to find include files.
     This option lets you define custom switches for your script.
     This option makes Perl search for the script file using the PATH 
     environment variable. It's mostly used with UNIX systems that don't
     support the #! Line. The docs/perlrun.htm documentation file that 
     comes with your Perl distribution has more information about this 
     This UNIX-based option turns on taint checking. Normally, these 
     checks are only done when running setuid or setgid.
     This UNIX-based option will let Perl do unsafe operations. 
     This option will display the version and patchlevel of your 
     Perl executable.
     This option prints warnings about unsafe programming practices.
     Newer versions of Perl (since 5.6.0) offer the pragma 'use warnings'
     and 'no warnings' which is more flexible than the command-line option.
     The use of -w is discouraged for new developments. 
     This option will let you extract a Perl script from the middle of
     a file. This feature comes in handy when someone has sent you a script 
     via e-mail. Perl will scan the input file looking for a #! line that 
     contains the word perl. When it is found, it will execute the script 
     until the __END__ token is found. If a directory name is specified 
     after the -x option, Perl will switch to that 
     directory before executing the script. 

Generated 8:01:33 on Jul 12, 2020