Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^4: time::piece Error parsing time at /usr/lib64/perl5/Time/Piece.pm line 469

by hippo (Bishop)
on Mar 07, 2018 at 09:01 UTC ( [id://1210445]=note: print w/replies, xml ) Need Help??


in reply to Re^3: time::piece Error parsing time at /usr/lib64/perl5/Time/Piece.pm line 469
in thread time::piece Error parsing time at /usr/lib64/perl5/Time/Piece.pm line 469

I read the docs on eval but I'm still unclear on what problem it resolved.

Perhaps this simplified code will illustrate?

#!/usr/bin/env perl use strict; use warnings; use Time::Piece; for my $input ('05/05/2000', 'notavaliddate') { my $date; if (eval { $date = Time::Piece->strptime($input, '%m/%d/%Y'); 1 }) + { print "Parsed '$input' into '$date' with eval\n"; } else { print "Attempted parsing of '$input' trapped by eval - life go +es on\n"; } if ($date = Time::Piece->strptime($input, '%m/%d/%Y')) { print "Parsed '$input' into '$date' without eval\n"; } else { # Next line never executed because program dies print "Attempted parsing of '$input' trapped without eval\n"; } } print "Run completed OK\n"; # This line will not be reached given bad +inputs
  • Comment on Re^4: time::piece Error parsing time at /usr/lib64/perl5/Time/Piece.pm line 469
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1210445]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2024-04-19 08:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found