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


in reply to localtime parse within hash init

NetWallah:

It may not be particularly elegent, but I'd just create a sub that returns the hash.

sub date_hash { my ($dtm, $rv) = (shift // time, {}); @{$r}{qw(sec min hour mday mon year wday yday isdst)} = localtime( +$dtm); return $rv; }

My reasons are:

Update: On the way in to work, I remembered that I *have* a similar function in my MCMUtils.pm package already, with a couple of changes:

I'll try to remember to update this node with the code for that function when I get back home. (It's not in my $work util packages (yet)).

...roboticus

When your only tool is a hammer, all problems look like your thumb.