Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: localtime parse within hash init

by NetWallah (Canon)
on Nov 04, 2014 at 06:49 UTC ( #1105979=note: print w/replies, xml ) Need Help??


in reply to Re: localtime parse within hash init
in thread localtime parse within hash init

Stackoverflow to the rescue!.

This works:

perl -MList::MoreUtils -E 'my %stuff=(otherinfo=>"this and that", dateinfo=>{List::MoreUtils::zip @{[qw|sec min hour mday mon year wday yday isdst|]} ,@{[localtime(time)]} }); say "sec=",$stuff{dateinfo}{sec}, " year=",$stuff{dateinfo}{year}'
From the article ....
... They technically don't need to be named, just dereferenced. e.g. @$ref and @{qw( foo bar )} work just as well as @a. In other words, it has to start with @ (and not be a slice). (ikegami)

Update:Loops(++) answered identically, at the same time I discovered this.

        "You're only given one little spark of madness. You mustn't lose it."         - Robin Williams

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2022-08-13 05:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?