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

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.

Replies are listed 'Best First'.
Re^5: strptime("%Y-%m") in perl6
by Laurent_R (Canon) on Feb 05, 2019 at 20:17 UTC
    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?