Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

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

by Laurent_R (Canon)
on Feb 05, 2019 at 17:04 UTC ( [id://1229421]=note: print w/replies, xml ) Need Help??


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?

Log In?
Username:
Password:

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

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

    No recent polls found