Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^4: strptime("%Y-%m") in perl6

by leszekdubiel (Scribe)
on Feb 05, 2019 at 17:34 UTC ( [id://1229423]=note: print w/replies, xml ) Need Help??


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?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1229423]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-18 00:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found