Syntax::Keyword::Try#
📦 std
A try statement with catch and finally blocks: the try block runs, an exception in it runs the catch block (catch ($e) puts the exception in a new lexical, catch ($e isa Class) and catch ($e =~ /re/) choose by it), and the finally block runs however the try was left. return, next, last and redo inside try act on the enclosing sub or loop, not on the block.
This is a native implementation of Syntax::Keyword::Try 0.31’s Try.xs on the XS::Parse::Keyword engine; its Syntax/Keyword/Try.pm and Syntax/Keyword/Try/Deparse.pm are used unchanged.
Synopsis#
use Syntax::Keyword::Try;
sub fetch {
try {
return attempt();
}
catch ($e) {
warn "It failed - $e";
return undef;
}
finally {
cleanup();
}
}
It binds the engine as XS consumers do, by boot_xs_parse_keyword.
Modules#
Syntax::Keyword::Try::Deparse- B::Deparse support for Syntax::Keyword::Try