next up previous contents
Next: Networking with Perl Up: Perl Command-Line Options Previous: Using the -s Option


This chapter covered the different command-line options that you can use with Perl. The options can also be referred to as switches because they turn different behaviors on and off.

The switches can be specified on the command line or using the #! line inside your script. If you use the #! line, try to place the options after the 32nd position to avoid inconsistent handling by different versions of UNIX.

The -n option is used to place your script inside of an input loop. The -p option uses the same loop, but also prints the $_ variable after each pass through the loop. The -a and -F options are used when you want the input lines to be split into the @F array.

Another very useful option is -i, which lets you edit files in-place. This option is good when you are doing a lot of text file manipulation.