Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Journal of nicholas (3034)

Friday January 09, 2009
06:22 AM

Today's mini WTF?

[ #38248 ]

use Time::Local();
my $time = timelocal(localtime());

Now that I've discovered this "idiom" lurking in the code base, I'm purging it.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • I keep finding:

    use Time::localtime;

    sub getCurrentTime {
        return \ctime();
    # and then, e.g.:
    my $time = ${&getCurrentTime};

  • Maybe it's intended. Check:

            $perl -MTime::Local -e 'warn timelocal(localtime(1224984600))'
            1224981000 at -e line 1.

    • Good point. I had assumed that it was an expensive no-op for all input values. However, the code in question has no special comments about detecting the 3600 seconds of the year when the wallclock time repeats. It usually seems to be about writing cookies that will expire in about 900 seconds, and I think it's just the long gone authors of the code again demonstrating that they weren't very good and didn't really understand what they were doing. (Which is partly why we now have 25% less code than 6 months a