Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: localtime parse within hash init

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


in reply to localtime parse within hash init

FWIW - this is the code I finally settled on ..
my %opt = ( DEBUG => 0, OTHER_UNRELATED_OPT => "Other values", # snip 8< --- more params here ... LOCALHOST => $ENV{HOSTNAME} || $ENV{COMPUTERNAME} || $E +NV{HOST}, DATEFIELD => sub{ local $_={}; @$_{qw|sec min hour mday mon year wday + yday isdst|} =localtime(time); $_->{year}+=1900; $_->{mon}+=1; $_->{yyyymmdd} = sprintf "%04d-%02d-%0 +2d", @$_{qw|year mon mday|}; $_->{hhmm} = sprintf "%02d:%02d", + @$_{qw|hour min|}; return $_} # end of anon sub ->(), # Call the sub REMOTE_PARAMS => "", );
Thanks everyone !

        "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://1106082]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2022-08-10 18:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?