From: gfx Date: Thu, 13 Aug 2009 06:48:58 +0000 (+0900) Subject: Add source printing code to Method::Generated that is contralled by $ENV{MOP_PRINT_SO... X-Git-Tag: 0.92~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=315ed13b7f11bc470c61b9f8c0ebd030e1180579;p=gitmo%2FClass-MOP.git Add source printing code to Method::Generated that is contralled by $ENV{MOP_PRINT_SOURCE} --- diff --git a/lib/Class/MOP/Method/Generated.pm b/lib/Class/MOP/Method/Generated.pm index 76f1ce6..63e2f76 100644 --- a/lib/Class/MOP/Method/Generated.pm +++ b/lib/Class/MOP/Method/Generated.pm @@ -12,6 +12,8 @@ our $AUTHORITY = 'cpan:STEVAN'; use base 'Class::MOP::Method'; +use constant _PRINT_SOURCE => $ENV{MOP_PRINT_SOURCE} ? 1 : 0; + ## accessors sub new { @@ -35,7 +37,7 @@ sub _eval_closure { my $e = do { local $@; local $SIG{__DIE__}; - $code = eval join + my $source = join "\n", ( map { /^([\@\%\$])/ @@ -48,6 +50,8 @@ sub _eval_closure { } keys %$__captures ), $_[2]; + print STDERR $_[0]->name, ' ', $source, "\n" if _PRINT_SOURCE; + $code = eval $source; $@; };