Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: localtime parse within hash init

by NetWallah (Canon)
on Nov 04, 2014 at 18:24 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2024-04-19 03:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found