Next | Trivial Utilities | 61 |
More hand-grown option processing:
my $FIELD = 'subject';
my $REVERSE = 1; # -1 means reverse, 1 means forward
while (@ARGV) {
local $_ = shift;
if (/^\+(.*)/) {
$FOLDER = $1;
} elsif (/^(-f|-fi|-fie|-fiel|-field)$/) {
$FIELD = shift;
} elsif (/^(?:-v|-ve|-ver|-verb|-verbo|-verbos|-verbose)$/) {
$VERBOSE = 1;
} elsif (/^(?:-r|-re|-rev|-reve|-rever|-revers|-reverse)$/) {
$REVERSE = -1;
} elsif (/^-/) {
warn "Unrecognized option '$_'\n";
$BAD=1;
} else {
$BAD=1;
}
}
Why didn't I just use Getopt::Long? I don't know.
The (?:-v|-ve|-ver|-verb|-verbo|-verbos|-verbose) garbage represents an experiment
But I never use anything but -v anyway
Next | Menu | Copyright © 2012 M. J. Dominus |