NAME

Try::Harder - Yet another pure-perl try/catch/finally module

SYNOPSIS

use Try::Harder;

# returns work as you would expect in other languages
sub foo
{
   try {
      attempt_a_thing();
      return "success"; # returns from the sub
   }
   catch {
      warn "It failed - $@";
      return "failure";
   }
}

DESCRIPTION

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.

RATIONALE

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.

CAVEATS

This code implements a source filter, so all standard caveats with that apply.

TODO

Test with fatpack

NOTES

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.