From: epg <> Date: Wed, 14 Apr 2004 18:16:22 +0000 (+0000) Subject: Switch from Getopt::Std to Getopt::Long and Pod::Usage. This is much X-Git-Url: https://diplodocus.org/git/minc/commitdiff_plain/484cb6c39c1ecbc1b3890e94f65946db82ff3b5e Switch from Getopt::Std to Getopt::Long and Pod::Usage. This is much better even though we don't use long options. --- diff --git a/minc b/minc index 743accc..3876514 100755 --- a/minc +++ b/minc @@ -32,8 +32,9 @@ use Errno; use Fcntl qw(O_WRONLY O_EXCL O_CREAT); use FileHandle; use File::stat; -use Getopt::Std; $Getopt::Std::STANDARD_HELP_VERSION = 1; +use Getopt::Long qw(:config gnu_getopt no_ignore_case); use POSIX qw(strftime WEXITSTATUS WIFEXITED); +use Pod::Usage; our $VERSION = 1; @@ -78,30 +79,23 @@ problem. =cut -my $dumpfilters = 0; +my $dumpfilters; +my $help; my $maxmsgs; -our $run = 1; -my $printfilenames = 0; - -my %opts; - -if (not getopts('dm:np', \%opts)) { - exit(2); -} - -if ($opts{'d'}) { - $dumpfilters = 1; -} elsif ($opts{'n'}) { - $run = 0; -} - -if (defined($opts{'m'})) { - $maxmsgs = $opts{'m'}; -} - -if ($opts{'p'}) { - $printfilenames = 1; -} +my $norun; +my $printfilenames; + +GetOptions( + 'd' => \$dumpfilters, + 'h|help' => \$help, + 'm=i' => \$maxmsgs, + 'n' => \$norun, + 'p' => \$printfilenames, + ) or pod2usage(); +$help and pod2usage(-exitstatus=>0, -verbose=>1); +scalar(@ARGV) == 0 or pod2usage(); + +our $run = !$norun; =head1 ENVIRONMENT