On Thu, Jul 02, 2015 at 03:21:11PM -0500, Tom Browder wrote:
> Okay, a second look shows me that's not quite as bad as I first though.
Another possibility is to let MAIN unpack the args for you, but then check
the exclusivity directly instead of using multisubs to do it:
sub MAIN(:$need, :$hope) {
unless $need.defined xor $hope.defined {
say "Usage: Exactly one of --need or --hope required";
exit 1;
}
# rest of MAIN goes here
}
Or use a one() junction, which reads quite nicely:
sub MAIN(:$need, :$hope) {
unless one( $need.defined, $hope.defined ) {
say "Usage: Exactly one of --need or --hope required";
exit 1;
}
# rest of MAIN goes here
}
Pm