From: nothingmuch Date: Wed, 14 May 2008 14:09:42 +0000 (+0000) Subject: r80567@dhcp117: nothingmuch | 2008-05-14 19:51:22 +0900 X-Git-Tag: v1.003015~114 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2bdaa93e26a2a3f82fc546d8ad548a51b6960e65;p=p5sagit%2FDevel-REPL.git r80567@dhcp117: nothingmuch | 2008-05-14 19:51:22 +0900 preserve $^H and %^H when using the LexEnv plugin git-svn-id: http://dev.catalyst.perl.org/repos/bast/trunk/Devel-REPL@4384 bd8105ee-0ff8-0310-8827-fb3f25b6796d --- diff --git a/lib/Devel/REPL/Plugin/LexEnv.pm b/lib/Devel/REPL/Plugin/LexEnv.pm index 71134f9..2d48746 100644 --- a/lib/Devel/REPL/Plugin/LexEnv.pm +++ b/lib/Devel/REPL/Plugin/LexEnv.pm @@ -12,6 +12,12 @@ has 'lexical_environment' => ( default => sub { Lexical::Persistence->new } ); +has '_hints' => ( + isa => "ArrayRef", + is => "rw", + predicate => '_has_hints', +); + around 'mangle_line' => sub { my $orig = shift; my ($self, @rest) = @_; @@ -20,8 +26,13 @@ around 'mangle_line' => sub { # Collate my declarations for all LP context vars then add ''; # so an empty statement doesn't return anything (with a no warnings # to prevent "Useless use ..." warning) - return join('', map { "my $_;\n" } keys %{$lp->get_context('_')}) - .qq{{ no warnings 'void'; ''; }\n}.$line; + return join('', + 'BEGIN { if ( $_REPL->_has_hints ) { ( $^H, %^H ) = @{ $_REPL->_hints } } }', + ( map { "my $_;\n" } keys %{$lp->get_context('_')} ), + qq{{ no warnings 'void'; ''; }\n}, + $line, + '; BEGIN { $_REPL->_hints([ $^H, %^H ]) }', + ); }; around 'execute' => sub {