in reply to How to convert time stamp to unix time ?

In addition to Time::Local which jettero mentioned, you could also use Date::Calc, DateTime, and for good measure Date::Manip.

Parsing hint:

my $stamp = "100117104030"; my ($YY, $MM, $DD, $hh, $mm, $ss) = ($stamp =~ /^(\d{2})(\d{2})(\d{2}) +(\d{2})(\d{2})(\d{2})/);

Replies are listed 'Best First'.
Re^2: How to convert time stamp to unix time ?
by AnomalousMonk (Archbishop) on Feb 03, 2010 at 14:47 UTC

    The regex
        /^(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/
    could surely be shortened to
        m{ \d{2} }xmsg

    >perl -wMstrict -le "my $stamp = '100117104030'; my ($YY, $MM, $DD, $hh, $mm, $ss) = $stamp =~ m{ \d{2} }xmsg; print $stamp; print qq{$YY $MM $DD $hh $mm $ss}; " 100117104030 10 01 17 10 40 30

      What are the "m" and the "s" for. :)

        They are magical charms against foot injury and late night hair loss. I make enough Stupid Regex Mistakes that I fear to be without them.

      And in this case,
         m{ \d{2} }xmsg

      could be
         /(\d\d)/g

        ... and, indeed,
            /\d\d/g