On 03.07.2017 13:09, Rick Measham wrote:
> I'm not sure what you mean by 'local DIE handlers'. Are you talking
> about defining a local $SIG{__DIE__} ?
>
Exactly. Most examples I saw are doing this, but since I don't catch any
signals anywhere else in my application, I think I don't need it. On the
other hand, you never know about other libraries / modules, so I
probably will do it nevertheless. After all, it won't hurt (to my best
knowledge).
> I've been out of perl for a couple of years, but surely you should just
> use eval{} ?
>
>
> $dt = eval { $parser->parse( $input );};
>
> if( $@ ){
>
> echo "Unable to parse your date ($input)\n";
>
> exit;
>
> }
>
> echo "Your date is $dt\n";
>
>
> - Rick
>
Yes, I'll follow everybody's advice and use eval, but I won't use $@.
The only thing I must know is if DateTime -> new() inside the eval has
died or not, so I'll just test if the eval return undef.
Thanks for your help!
Regards,
Binarus