From 691c1f74f58b14270d246fb78e2697d718822079 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Wed, 10 Jul 2013 10:16:11 -0400 Subject: only add newly declared variables here --- lib/Reply/Plugin/LexicalPersistence.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Reply/Plugin/LexicalPersistence.pm b/lib/Reply/Plugin/LexicalPersistence.pm index 2e972bf..8286aef 100644 --- a/lib/Reply/Plugin/LexicalPersistence.pm +++ b/lib/Reply/Plugin/LexicalPersistence.pm @@ -5,7 +5,7 @@ use warnings; use base 'Reply::Plugin'; -use PadWalker 'peek_sub'; +use PadWalker 'peek_sub', 'closed_over'; =head1 SYNOPSIS @@ -36,9 +36,12 @@ sub compile { my ($code) = $next->($line, %args); + my $new_env = peek_sub($code); + delete $new_env->{$_} for keys %{ closed_over($code) }; + $self->{env} = { %{ $self->{env} }, - %{ peek_sub($code) }, + %$new_env, }; return $code; -- cgit v1.2.3-54-g00ecf