- publishing free software manuals
Perl Language Reference Manual
by Larry Wall and others
Paperback (6"x9"), 724 pages
ISBN 9781906966027
RRP £29.95 ($39.95)

Sales of this book support The Perl Foundation! Get a printed copy>>>


enables rudimentary switch parsing for switches on the command line after the program name but before any filename arguments (or before an argument of -{-}). Any switch found there is removed from @ARGV and sets the corresponding variable in the Perl program. The following program prints "1" if the program is invoked with a -xyz switch, and "abc" if it is invoked with -xyz=abc.

#!/usr/bin/perl -s
if ($xyz) { print "$xyz\n" }

Do note that a switch like -{-help} creates the variable ${-help}, which is not compliant with strict refs. Also, when using this option on a script with warnings enabled you may get a lot of spurious "used only once" warnings.

ISBN 9781906966027Perl Language Reference ManualSee the print edition