Skip to content

Commit

Permalink
Be cleverer about argument parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
davorg committed Mar 24, 2017
1 parent f4cf411 commit ccf2744
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Lotto.pm
Expand Up @@ -44,7 +44,11 @@ sub parse_args {
my @errs;

if (@_ == 2) {
$type = shift;
($type, $count) = (shift, shift);
($type, $count) = ($count, $type) if $count =~ /\D/;
if ($count =~ /\D/) {
push @errs, "$count doesn't look like a positive integer";
}
if (! exists $config->{$type}) {
push @errs, qq["$type" is not a recognised type of lottery];
}
Expand Down

0 comments on commit ccf2744

Please sign in to comment.