X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FEval-WithLexicals.git;a=blobdiff_plain;f=lib%2FEval%2FWithLexicals.pm;h=0f9c2facb46129732e2c1116ce33e1122a2dd612;hp=752de55660db68b4a9fd7e031e4507a4982130be;hb=a214c345e2de0ddd1e2ab205d942e2b1d7bb47b1;hpb=8d732f3064bb88d682504f365ef1af62c6598b8c diff --git a/lib/Eval/WithLexicals.pm b/lib/Eval/WithLexicals.pm index 752de55..0f9c2fa 100644 --- a/lib/Eval/WithLexicals.pm +++ b/lib/Eval/WithLexicals.pm @@ -4,7 +4,7 @@ use Moo; use Moo::Role (); use Sub::Quote; -our $VERSION = '1.001000'; # 1.1.0 +our $VERSION = '1.003002'; # 1.3.2 $VERSION = eval $VERSION; has lexicals => (is => 'rw', default => quote_sub q{ {} }); @@ -17,7 +17,7 @@ has lexicals => (is => 'rw', default => quote_sub q{ {} }); isa => sub { my ($val) = @_; die "Invalid context type $val - should be list, scalar or void" - unless $valid_contexts{$val}; + unless $valid_contexts{$val}; }, ); } @@ -69,7 +69,8 @@ ${to_eval} ${capture_code} sub Eval::WithLexicals::Cage::grab_captures { no warnings 'closure'; no strict 'vars'; - package Eval::WithLexicals::VarScope;!; + package! # hide from PAUSE + .q! Eval::WithLexicals::VarScope;!; # rest is appended by Eval::WithLexicals::Util::capture_list, called # during parsing by the BEGIN block from capture_code. @@ -123,13 +124,14 @@ sub _eval_do { } { - package Eval::WithLexicals::Util; + package # hide from PAUSE + Eval::WithLexicals::Util; use B qw(svref_2object); sub capture_list { my $pad_capture = \&Eval::WithLexicals::Cage::pad_capture; - my @names = grep $_ ne '&', map $_->PV, grep $_->isa('B::PV'), + my @names = grep defined && length && $_ ne '&', map $_->PV, grep $_->can('PV'), svref_2object($pad_capture)->OUTSIDE->PADLIST->ARRAYelt(0)->ARRAY; $Eval::WithLexicals::current_code .= '+{ '.join(', ', map "'$_' => \\$_", @names).' };' @@ -137,6 +139,9 @@ sub _eval_do { } } +1; +__END__ + =head1 NAME Eval::WithLexicals - pure perl eval with persistent lexical variables @@ -259,6 +264,8 @@ Matt S. Trout David Leadbeater +haarg - Graham Knop (cpan:HAARG) + =head1 COPYRIGHT Copyright (c) 2010 the Eval::WithLexicals L and L @@ -270,5 +277,3 @@ This library is free software and may be distributed under the same terms as perl itself. =cut - -1;