in reply to Re^2: strptime("%Y-%m") in perl6
in thread strptime("%Y-%m") in perl6

Nor sure to really understand your requirement, but what about this:
> for <1 5 3 13> -> $month { say Date.new(2019, $month, 1 )} 2019-01-01 2019-05-01 2019-03-01 Month out of range. Is: 13, should be in 1..12 in block <unit> at <unknown file> line 1

Replies are listed 'Best First'.
Re^4: strptime("%Y-%m") in perl6
by leszekdubiel (Scribe) on Feb 05, 2019 at 17:34 UTC
    I need to check command line args. I expected perl6 to be simple as:
    "parse ARGS[0] as %Y-%m od die"
    Just one sentence without additional ARGS[0] manipulation.
      In Perl6, the special MAIN subroutine, if any, receives the arguments passed to the program and can be used to check their type and validity:
      ~ perl6 -e 'sub MAIN (Int $month where 1 <= $month <= 12) {say "Succes +s";}' 4 Success ~ perl6 -e 'sub MAIN (Int $month where 1 <= $month <= 12) {say "Succes +s";}' 14 Usage: -e '...' <month> ~ perl6 -e 'sub MAIN (Int $month where 1 <= $month <= 12) {say "Succes +s";}' 8.5 Usage: -e '...' <month>
      Is this the type of thing you're after?