Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. use Getopt::Long qw( );
  2.  
  3. Getopt::Long::Configure(qw( posix_default bundling ));
  4. Getopt::Long::GetOptions(
  5.    'help|h|?' => \&help,
  6.    foo        => \$opt_foo,
  7.    bar        => \$opt_bar,
  8. )
  9.    or usage();
  10.  
  11. # -vs-
  12.  
  13. while (@ARGV && $ARGV[0] =~ /^-/) {
  14.    for (shift(@ARGV)) {
  15.       $_ eq '--' and last;
  16.       /^(?:--help|-?h|-\?)\z/ and help();
  17.       $_ eq '--foo' and $opt_foo = 1, next;
  18.       $_ eq '--bar' and $opt_bar = 1, next;
  19.       usage("Unrecognized option \"$_\"");
  20.    }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement