Sorry to heat up this stale topic, but I've just been bitten by this:
#!/usr/bin/perl
use Modern::Perl '2015';
use Try::Tiny;
sub foo {
try {
say 'foo try';
die;
return 'try';
}
catch {
say 'foo catch';
return 'catch';
};
say 'foo outer';
return 'outer';
}
sub bar {
eval {
say 'bar try';
die;
return 'try';
} or do {
say 'bar catch';
return 'catch';
};
say 'fos outer';
return 'outer';
}
say 'begin';
my $r = foo();
say $r;
say "########";
my $s = bar();
say $s;
say 'end';
So there is a subtle difference between eval ... or do and Try::Tiny: in the latter, return doesn't mean what you think it means even in the catch block.
In hindsight, it's obvious, and it is even documented explicitly, still, this behavior makes Try::Tiny slightly more inconvenient.