NAME

Getopts::Casual - A simpler, kinder replacement for Getopt::*.

SYNOPSIS

use Getopt::Casual;

print $_, ' = ', $ARGV{ $_ }, "\n" for keys %ARGV if $ARGV{ '--demo' };

(see example.pl)

DESCRIPTION

Getopt::Casual affords a person writing a command line utility the ability to not have to predeclare command line switches. Instead, the programmer can check the keys of %ARGV to see if an argument exists. The arguments can have a value or simply be set to 1, depending on the following basic rules:

1) Arguments can be single characters or and combination of characters.

2) Arguments that begin with a '-' followed by a string, which can include spaces if the string is enclosed by quotes, will have the value of that string.

3) Arguments that begin with a '-' followed by another string that begins with a '-', including quoted strings that contain spaces, will have a value of 1.

4) Arguments that do not begin with a '-' will have a value of one. When preceded by an odd number of arguments that begin with a dash, this string is a value of the previous command line argument.

5) All arguments of the script can be found as either a key or a value of %ARGV in the callers namespace.

EXAMPLES

See the included program called example.pl.

./example.pl a a a a = 1

./example.pl a b a = 1 b = 1

./example.pl a -b a = 1 -b = 1

./example.pl -a b -a = b

./example.pl -a -b -a = 1 -b = 1

./example.pl --debug 2 --debug = 2

./example.pl -debug 2 -debug = 2

BUGS

If you find one, please tell me or supply a patch.

SEE ALSO

Getopt::Std, Getopt::Long

NOTES

There has been some doubt as to whether or not this was useful enough to have to remember to tote it with you to every system on which you had command line perl scripts. The obvious advantage of the core modules is that they are wherever perl is installed. If portablity is really a key issue, use the core modules.

AUTHOR

Daniel M. Lipton <photo@tiac.net>