in reply to old code revisited

Also, it's best to call localtime only once and do your manipulations on that (as you did in the array version). If your function version had started at 23:59:59 and took any longer to run than a second, your results would have been wonky. Looks like you got lucky all this time. :-)

"One word of warning: if you meet a bunch of Perl programmers on the bus or something, don't look them in the eye. They've been known to try to convert the young into Perl monks." - Frank Willison