X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FDevel-REPL.git;a=blobdiff_plain;f=lib%2FDevel%2FREPL%2FPlugin%2FPackages.pm;h=77fdebdc5e5d05180ce8af1d27edfd9f5a60bdca;hp=1c149e23df2f28233def95c684d62f3b8f200cd3;hb=1716b20061af51ca82cc543f618f19c1e20f2efa;hpb=ae5e19ec178afa6178efb13d556c781800ece6ca diff --git a/lib/Devel/REPL/Plugin/Packages.pm b/lib/Devel/REPL/Plugin/Packages.pm index 1c149e2..77fdebd 100644 --- a/lib/Devel/REPL/Plugin/Packages.pm +++ b/lib/Devel/REPL/Plugin/Packages.pm @@ -1,7 +1,11 @@ +use strict; +use warnings; package Devel::REPL::Plugin::Packages; +use Devel::REPL::Plugin; -use Moose::Role; -use vars qw($PKG_SAVE); +use namespace::autoclean; + +our $PKG_SAVE; has 'current_package' => ( isa => 'Str', @@ -24,14 +28,15 @@ around 'mangle_line' => sub { my $line = $self->$orig(@args); # add a BEGIN block to set the package around at the end of the sub # without mangling the return value (we save it off into a global) - $line .= '; BEGIN { $Devel::REPL::Plugin::Packages::PKG_SAVE = __PACKAGE__; }'; + $line .= ' +; BEGIN { $Devel::REPL::Plugin::Packages::PKG_SAVE = __PACKAGE__; }'; return $line; }; after 'execute' => sub { my ($self) = @_; # if we survived execution successfully, save the new package out the global - $self->current_package($PKG_SAVE); + $self->current_package($PKG_SAVE) if defined $PKG_SAVE; }; around 'eval' => sub { @@ -47,3 +52,12 @@ package Devel::REPL::Plugin::Packages::DefaultScratchpad; # declare empty scratchpad package for cleanliness 1; + +__END__ + +=head1 NAME + +Devel::REPL::Plugin::Packages - Keep track of which package the user is in + +=cut +