Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: Which incarnation of try/catch to use?

by mldvx4 (Friar)
on Oct 03, 2023 at 07:49 UTC ( [id://11154804] : note . print w/replies, xml ) Need Help??


in reply to Re: Which incarnation of try/catch to use?
in thread Which incarnation of try/catch to use?

Aha! There was one of the problems, I had been using eval { ... }; if ($@) { ... } instead of eval { ...; 1 } or do { ... }; and the latter worked as intended, trapping the error raised in a deeper module by bad data. I've tracked down the cause of my script making the bad data now but have to redesign a bit of the work flow.

After that, I folded the core "try" feature now, with good results. Although the script now warns that "try" is experimental.

Replies are listed 'Best First'.
Re^3: Which incarnation of try/catch to use?
by eyepopslikeamosquito (Archbishop) on Oct 03, 2023 at 08:10 UTC

    Although the script now warns that "try" is experimental.

    See the sample code in New built-in perl5.38 try/catch syntax that silences the warning via:

    # use feature 'try'; # throws 'try/catch is experimental' warnings use experimental 'try';