X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FEval-WithLexicals.git;a=blobdiff_plain;f=lib%2FEval%2FWithLexicals%2FWithHintPersistence.pm;h=642887ca9df03424b11e8fba9d527757004a8045;hp=d6a4ac0a60b7a641a12057dec91afd2f9a7bbd0d;hb=bbc1a33fecb81112da93d423db1647a5c9a423bd;hpb=14786ff863ce8fbc95583e3a39b9ca29c4f0958c diff --git a/lib/Eval/WithLexicals/WithHintPersistence.pm b/lib/Eval/WithLexicals/WithHintPersistence.pm index d6a4ac0..642887c 100644 --- a/lib/Eval/WithLexicals/WithHintPersistence.pm +++ b/lib/Eval/WithLexicals/WithHintPersistence.pm @@ -5,19 +5,11 @@ use Sub::Quote; our $VERSION = '1.002000'; # 1.2.0 $VERSION = eval $VERSION; -# Used localised -our($hints, %hints); - has hints => ( is => 'rw', default => quote_sub q{ {} }, ); -has _first_eval => ( - is => 'rw', - default => quote_sub q{ 1 }, -); - around eval => sub { my $orig = shift; my($self) = @_; @@ -28,6 +20,11 @@ around eval => sub { my @ret = $orig->(@_); $self->hints({ Eval::WithLexicals::Cage::capture_hints() }); + $self->prelude( + join '', q[ BEGIN { ], + _capture_unroll_global('$Eval::WithLexicals::Cage::hints', $self->hints, 2), + q[ } ], + ); @ret; }; @@ -46,22 +43,6 @@ sub _capture_unroll_global { ); } -sub setup_code { - my($self) = @_; - # Only run the prelude on the first eval, hints will be set after - # that. - if($self->_first_eval) { - $self->_first_eval(0); - return $self->prelude; - } else { - # Seems we can't use the technique of passing via @_ for code in a BEGIN - # block - return q[ BEGIN { ], - _capture_unroll_global('$Eval::WithLexicals::Cage::hints', $self->hints, 2), - q[ } ], - } -}; - around capture_code => sub { my $orig = shift; my($self) = @_;