sub try my try catch eval try if local catch sub catch try die phooey

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
sub try (&@) {
my($try,$catch) = @_;
eval { &$try };
if ($@) {
local $_ = $@;
&$catch;
}
}
sub catch (&) { $_[0] }
try {
die "phooey";
} catch {
/phooey/ and print "unphooey\n";
};