you can use Try::Tiny or Syntax::Keyword::Try module. From the synopis of the modules:
use Try::Tiny; # handle errors with a catch handler try { die "foo"; } catch { warn "caught error: $_"; # not $@ }; # or use Syntax::Keyword::Try; sub foo { try { attempt_a_thing(); return "success"; } catch { warn "It failed - $@"; return "failure"; } }
Also look at ModernPerl book in the chapter dedicated to Exceptions.
L*
In reply to Re: Exception clauses
by Discipulus
in thread Exception clauses
by betmatt
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |