diff options
-rw-r--r-- | lib/Reply/Plugin/LexicalPersistence.pm | 7 |
1 files 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; |