X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FClass%2FMOP%2FMethod%2FGenerated.pm;h=ea0ea2c8b103af06243b2452d925f572c97b4354;hb=e24b19fbbf5a62172dad0d8dfb86e03eed9a51c1;hp=5af96b8776729d98b0de36f46eee14a13985875b;hpb=e4da508a1801f8bf4164d9f5ecbaf96cb343e5aa;p=gitmo%2FClass-MOP.git diff --git a/lib/Class/MOP/Method/Generated.pm b/lib/Class/MOP/Method/Generated.pm index 5af96b8..ea0ea2c 100644 --- a/lib/Class/MOP/Method/Generated.pm +++ b/lib/Class/MOP/Method/Generated.pm @@ -29,22 +29,29 @@ sub _initialize_body { sub _eval_closure { # my ($self, $captures, $sub_body) = @_; my $__captures = $_[1]; - eval join( - "\n", - ( + + my $code; + + my $e = do { + local $@; + local $SIG{__DIE__}; + $code = eval join + "\n", ( map { /^([\@\%\$])/ or die "capture key should start with \@, \% or \$: $_"; - q[my ] - . $_ . q[ = ] - . $1 - . q[{$__captures->{'] - . $_ - . q['}};]; - } keys %$__captures - ), - $_[2] - ); + q[my ] + . $_ . q[ = ] + . $1 + . q[{$__captures->{'] + . $_ . q['}};]; + } keys %$__captures + ), + $_[2]; + $@; + }; + + return ( $code, $e ); } sub _add_line_directive {