Re: How to check if a DateTime is invalid (again - but this time without using eval)?

[email protected] (Binarus) Thu, 6 Jul 2017 08:44:29 +0200
Newsgroups perl.datetime
Message-ID <[email protected]>
On 05.07.2017 16:59, Thomas (HFM) Wyant wrote:

> One of the edge cases with eval {} is the possibility that $@ gets
> clobbered before you get your hands on it.

I don't care about this since I don't use $@ (see my previous posts).

> my $dt = eval { $parser->parse( $input ) }
> or die "Unable to parse your date ($input)\n";

This is the way I want to go. In my case, the eval even doesn't need to
explicitly return something. The only thing I am interested in is if
DateTime -> new() has died inside the eval or not. In case it has, the
eval will return undef; in case it hasn't, eval will return a valid
date-time.

Thank you very much for your help!

Regards,

Binarus