NAME

Getopt::WonderBra - Lift and Separate Command Line Options

SYNOPSIS

use Getopt::WonderBra; @ARGV = getopt( 'opts:-:', @ARGV ); print Dumper( \@ARGV ); sub help() { print "Useless help message"; }; sub version() { print "Useless version message"; }; while ( ( $_ = shift ) ne '--' ) { if (/^-o$/) { $opt_o++ } elsif (/^-p$/) { $opt_p++ } elsif (/^-t$/) { $opt_t++ } elsif (/^-s$/) { push( @opt_s, shift ); } elsif (/^--/) { push( @opt_long, $_ ); } else { die 'I do not grok -', $_; } } while (<>) { print; }

REQUIRES

perl5.008006, Carp, Exporter

EXPORTS

getopt($@) also wraps main::help(@) and main::version(), or exports it's own (nearly worthless) versions if they do not exist.

DESCRIPTION

See example.pl for an example of usage.

There just weren't enough command line processessing modules, so I had to write my own. Actually, it exists because it made it easy to port shell scripts to perl: it acts just like the getopt program. Oddly, none of the modules that are actually named after it do. (Though some act like the C function) The following sequence chops your args up and gives 'em to you straight:

HELP

main::help(), if it exists, is wrapped by this module. This is done to ensure correct behavior for programs that use getopt. (e.g. error messages to stdout if --help in specified, so $ foo --help | less has the desired results)

The wrapping has the following effects:

  • If no args are passed to main::help, STDOUT will be selected before your sub is called, and the program will exit 0.

VERSION

If you define a main::version() sub, it will be called if the user specified --version, and the program will terminate.

STDOUT will always be selected.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 55:

=over should be: '=over' or '=over positive_number'