in reply to Try::Tiny vs. TryCatch: assigning a value to a variable inside of the try-block

With regard to choosing the catch block based on the class of the exception thrown (I presume you are using something like Class::Exception or Throwable) have you considered a dispatch table?

# this is a very crude concept example my $val = try { some_operation(); } catch { if ( blessed($_) ) { &{$exceptions_by_class{blessed($_)}}($_); } else { # handle normal die or croak message ... } };

I must confess that I am a big fan of Try::Tiny and have not played with TryCatch.

Update: fixed typo in code.

You must always remember that the primary goal is to drain the swamp even when you are hip-deep in alligators.
  • Comment on Re: Try::Tiny vs. TryCatch: assigning a value to a variable inside of the try-block
  • Download Code