require 5;
use strict;
# Rather like Getopt::Std's getopts
# Call Pod::Perldoc::GetOptsOO::getopts($object, \@ARGV, $truth)
# Given -n, if there's a opt_n_with, it'll call $object->opt_n_with( ARGUMENT )
# (e.g., "-n foo" => $object->opt_n_with('foo'). Ditto "-nfoo")
# Otherwise (given -n) if there's an opt_n, we'll call it $object->opt_n($truth)
# (Truth defaults to 1)
# Otherwise we try calling $object->handle_unknown_option('n')
# (and we increment the error count by the return value of it)
# If there's no handle_unknown_option, then we just warn, and then increment
# the error counter
#
# The return value of Pod::Perldoc::GetOptsOO::getopts is true if no errors,
# otherwise it's false.
#
## sburke@cpan.org 2002-10-31
BEGIN { # Make a DEBUG constant ASAP
: sub(){10};
}
sub getopts {
"Starting switch processing. Scanning arguments [@$args]\n"
return unless @$args;
my $error_count = 0;
if ($_ eq '--') { # early exit if "--"
shift @$args;
last;
}
my $method = "opt_${first}_with";
shift @$args;
warn "Option $first needs a following argument!\n" unless @$args;
} else { # like -fbar (== -f bar)
shift @$args;
}
# Otherwise, it's not argumental...
} else {
# Otherwise it's an unknown option...
DEBUG > 3
and print " calling handle_unknown_option('$first')\n";
$error_count += (
);
} else {
++$error_count;
warn "Unknown option: $first\n";
}
shift @$args
} else { # like -fbar (== -f -bar )
}
}
}
"Ending switch processing. Args are [@$args] with $error_count errors.\n"
$error_count == 0;
}
1;