Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use Getopt::Long qw( );
- Getopt::Long::Configure(qw( posix_default bundling ));
- Getopt::Long::GetOptions(
- 'help|h|?' => \&help,
- foo => \$opt_foo,
- bar => \$opt_bar,
- )
- or usage();
- # -vs-
- while (@ARGV && $ARGV[0] =~ /^-/) {
- for (shift(@ARGV)) {
- $_ eq '--' and last;
- /^(?:--help|-?h|-\?)\z/ and help();
- $_ eq '--foo' and $opt_foo = 1, next;
- $_ eq '--bar' and $opt_bar = 1, next;
- usage("Unrecognized option \"$_\"");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement