in reply to golfing on localtime

Sorry, in trying to "motivate" the problem, I've managed to explain the question badly.

I know about strftime, it's right in the perldoc for localtime. What I was more interested in was the question at the end. I was just curious if there was some goatse-operator-esque way of tweaking a list without going through an intermediary variable. I know, it's a stupid question.

Replies are listed 'Best First'.
Re^2: golfing on localtime
by Corion (Patriarch) on Jul 18, 2006 at 14:30 UTC

    As long as you only have adjustments of numbers, I'd go for List::MoreUtils' zip function:

    my @adjustments = ( +1900, +1, 0, 0, 0, 0, ); my @t = pairwise { $a+$b } @adjustments, @{[localtime]};

    If the operation differs between the elements of the target list/array, I guess a multi-map / MapCar is what you'll need:

    my @adjustments = ( sub { $_[0] + 1900 }, sub { $_[0] + 1 }, sub { $_[0] + 0 }, ... ); my @t = pairwise { $a->($b) } @adjustments, @{[localtime]};