in reply to Re: Error parsing using Time::Piece
in thread Error parsing using Time::Piece

This is the line the gives me the error:
... my $date = Time::Piece->strptime("32015", "%m%Y");

Replies are listed 'Best First'.
Re^3: Error parsing using Time::Piece
by jeffa (Bishop) on Apr 28, 2015 at 18:54 UTC

    You will need to add a leading zero to that:

    my $date = Time::Piece->strptime("032015", "%m%Y");

    Maybe you could use sprintf?

    perl -MTime::Piece -le'print Time::Piece->strptime( sprintf( "%06d", " +32015"), "%m%Y" )'

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
      It seems that if I convert this line in my code from:
      my $last_month_num = $t->add_months(-1)->mon;

      to:
      my $last_month_num = sprintf("%02d",$t->add_months(-1)->mon);

      It should take care of the problem!