use diagnostics; use warnings; use strict; my $a_code =<<'CODE'; sub tryme { my $foo = shift; return $foo + 2; } CODE # Intent shown here does _not_ work my $ans = eval{ $a_code; tryme( 3 ); } or die "doesn't work";