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=bbaa35289a1f8dc1413452ca9bf6824ebae0549e;hp=e0b797b6d1f42a2c9dca2f71198078b06b846a6e;hb=5ac988901b5ccbf3b31cdf980534d0c9631d9e4a;hpb=9cfc1536ce713631d93a1d4d11259d1103fb9cae diff --git a/lib/Devel/REPL/Plugin/Packages.pm b/lib/Devel/REPL/Plugin/Packages.pm index e0b797b..bbaa352 100644 --- a/lib/Devel/REPL/Plugin/Packages.pm +++ b/lib/Devel/REPL/Plugin/Packages.pm @@ -1,9 +1,14 @@ +use strict; +use warnings; package Devel::REPL::Plugin::Packages; -use Devel::REPL::Plugin; +# ABSTRACT: Keep track of which package the user is in + +our $VERSION = '1.003028'; -use namespace::clean -except => [ "meta" ]; +use Devel::REPL::Plugin; +use namespace::autoclean; -use vars qw($PKG_SAVE); +our $PKG_SAVE; has 'current_package' => ( isa => 'Str', @@ -26,14 +31,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 { @@ -44,7 +50,8 @@ around 'eval' => sub { return $self->$orig(@args); }; -package Devel::REPL::Plugin::Packages::DefaultScratchpad; +package # hide from PAUSE + Devel::REPL::Plugin::Packages::DefaultScratchpad; # declare empty scratchpad package for cleanliness