Try::Harder - Yet another pure-perl try/catch/finally module
# returns work as you would expect in other languages
return "success"; # returns from the sub
warn "It failed - $@";
This module provides sane try/catch/finally syntax for perl that is (mostly) semantically compatible with the syntax plugin Syntax::Keyword::Try, but implemented in pure-perl using source filters. However, if you already have Syntax::Keyword::Try installed it uses that instead.
Please see the Syntax::Keyword::Try documentation for usage and such.
Sometimes you don't have a version of perl new enough to use Syntax::Keyword::Try, but really want its nice syntax. Or perhaps you really need your code to be pure-perl for various reasons.
This code implements a source filter, so all standard caveats with that apply.
Test with fatpack
See the post-filtered code by running this:
TRY_HARDER_USE_PP=1 perl -c -Ilib -MFilter::ExtractSource test.pl > transformed.pl
This module tries very hard to not change the line-count of your code, so the generated code is *very* dense.
This is free software; you may redistribute it and/or modify it under the same terms as the Perl 5 programming language itself.
To install Try::Harder, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.