next up previous contents
Next: The Command-line Options Up: Perl Command-Line Options Previous: Perl Command-Line Options

How Are the Options Specified?

The most frequent way to specify command-line options is on the command line. All of Perl's options are specified using a dash and then a single character followed by arguments, if needed. For example,

 perl -I/usr/~dave/include script.pl

You can combine options with no arguments with the following switch. The following two command lines are equivalent.

perl -cI/usr/~dave/include script.pl
perl -c -I/usr/~dave/include script.pl

You can also specify command-line options inside your script file using the #! line. Just place them following the directory or executable name. If you are working on a UNIX system, you are probably familiar with using the #! notation to tell the system where to find the Perl executable. The various UNIX systems and Windows can interpret the #! line in different ways. Therefore, Perl starts parsing the #! switches immediately after the first instance of perl on the line. For example, if you started your script with this line:

#!/bin/perl -w

Then Perl will run with the -w option in effect.

Note Some UNIX systems will only read the first 32 characters of the #! line. So try to have your options end before the 32nd position if you require them the be called.


next up previous contents
Next: The Command-line Options Up: Perl Command-Line Options Previous: Perl Command-Line Options
dave@cs.cf.ac.uk