SPUG: Getting the current time perl snippet on TheDailyWTF

Chris Wilkes cwilkes-spug at ladro.com
Wed Jan 11 17:14:44 PST 2006

Saw this in that website's RSS feed for today:


Without many of the built-in date/time functions found in other
languages, some Perl users can find themselves having to write some
interesting code in order to get the results they want. Sure, it's
pretty easy to reference the DateTime module, or a whole host of other
modules to help with this, but who wants to use code that someone else
invented? Some resort to fiddling with the number of seconds since epoch
returned by the time() function. Others, such as Mike's predecessor,
issue an operating system command to write the date out to text file,
read the file back in, parse it, and use the result ...

    #write out date
    system("date >/tmp/the.date");

    #read it back in
    open(THEDATE, "</tmp/the.date");
    while (<THEDATE>) 
      @datevals = split(/ /,$_);

More information about the spug-list mailing list