develooper Front page | perl.datetime | Postings from July 2017

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

Thread Previous | Thread Next
From:
Binarus
Date:
July 6, 2017 06:44
Subject:
Re: How to check if a DateTime is invalid (again - but this timewithout using eval)?
Message ID:
6f6509c7-4a39-e204-0bd8-0a1c2105ead7@binarus.de
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

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About