in reply to Re: How to convert time stamp to unix time ?
in thread How to convert time stamp to unix time ?

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

Replies are listed 'Best First'.
Re^3: How to convert time stamp to unix time ?
by Your Mother (Archbishop) on Feb 03, 2010 at 18:27 UTC

    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.

Re^3: How to convert time stamp to unix time ?
by Anonymous Monk on Feb 03, 2010 at 17:54 UTC

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

    could be
       /(\d\d)/g

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