http://qs321.pair.com?node_id=1105972

NetWallah has asked for the wisdom of the Perl Monks concerning the following question:

Gentle Monks,

I'm trying to get an "elegant" solution to initializing a hash such that it includes a parsed date (i.e. pieces of the date are easily accessible).

I'd like to do it all within the hash init (no separate statements). I have the following working solution:

perl -E 'my %stuff=(otherinfo=>"this and that", dateinfo=>{local %_, map({()} @_{qw|sec min hour mday mon year wday yday isdst|} =localtime(time)), %_}); say "sec=",$stuff{dateinfo}{sec}, " year=",$stuff{dateinfo}{year}' #-- Output -- #sec=2 year=114
I'm hoping wiser monks could help me get rid of the hack (ab)use of "map", and %_ and make this more "elegant" and/or canonical.

Thank you.

Update: I'm also curious how this would look in perl6. (zip, perhaps ?)

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