Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

what does
#!/usr/bin/perl -n #!/usr/bin/perl -p
mean? and where would I find a list of all of the available switches?

Replies are listed 'Best First'.
Re: the shebang
by ColtsFoot (Chaplain) on Jul 14, 2001 at 11:40 UTC
    Entering perl --help at a shell prompt yields the following:-
    $ perl --help Usage: perl [switches] [--] [programfile] [arguments] -0[octal] specify record separator (\0, if no argument) -a autosplit mode with -n or -p (splits $_ into @F) -c check syntax only (runs BEGIN and END blocks) -d[:debugger] run scripts under debugger -D[number/list] set debugging flags (argument is a bit mask or flags +) -e 'command' one line of script. Several -e's allowed. Omit [prog +ramfile]. -F/pattern/ split() pattern for autosplit (-a). The // +'s are optional. -i[extension] edit <> files in place (make backup if extension sup +plied) -Idirectory specify @INC/#include directory (may be used more th +an once) -l[octal] enable line ending processing, specifies line termin +ator -[mM][-]module.. executes `use/no module...' before executing your s +cript. -n assume 'while (<>) { ... }' loop around your script -p assume loop like -n but print line also like sed -P run script through C preprocessor before compilation -s enable some switch parsing for switches after script + name -S look for the script using PATH environment variable -T turn on tainting checks -u dump core after parsing script -U allow unsafe operations -v print version number, patchlevel plus VERY IMPORTANT + perl info -V[:variable] print perl configuration information -w TURN WARNINGS ON FOR COMPILATION OF YOUR SCRIPT. Rec +ommended. -x[directory] strip off text before #!perl line and perh +aps cd to directory Complete documentation for Perl, including FAQ lists, should be found +on this system using `man perl' or `perldoc perl'. If you have access to + the Internet, point your browser at http://www.perl.com/, the Perl Home Pa +ge.
    HTH

      See also "perldoc perlrun" or perlman:perlrun for more details.

              - tye (but my friends call me "Tye")
Re: the shebang
by Zaxo (Archbishop) on Jul 14, 2001 at 11:37 UTC

    Shebang is the Unixish convention for selecting which program will interpret a shell script.

    Perl command line options are documented in perldoc perlrun or man perlrun.

    After Compline,
    Zaxo

Re: the shebang
by jlongino (Parson) on Jul 15, 2001 at 00:19 UTC
    Probably the best resource is Programming Perl (3rd Edition) by Larry Wall, Tom Christiansen, Jon Orwant (Paperback - 1067 pages 3rd edition, July 2000 O'Reilly & Associates; ISBN: 0596000278). Every Perl programmer should have this book.

    However, you can find many good online resources. Here are a few, but the first is the most closely related to your question and include some examples:
    Perl Command-Line Options (specifically Using the -n and -p options)
    A more complete reference can be found at:
    Excerpts from Perl 5 by example by David Medinets
    You might also want to download and install Copernic 2001, by Copernic Technologies (available for Windows box). It has found many resources for me that I couldn't find via places like perldoc.com, perl.org, or CPAN.

    Hope these help are of help.