From: Sartak Date: Tue, 6 May 2008 08:39:31 +0000 (+0000) Subject: Refactor to make it easier to add print/warn to the session X-Git-Tag: v1.003015~117 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FDevel-REPL.git;a=commitdiff_plain;h=a4c582b6aeeb886dd9e8a958b5687062b9095f31 Refactor to make it easier to add print/warn to the session git-svn-id: http://dev.catalyst.perl.org/repos/bast/trunk/Devel-REPL@4345 bd8105ee-0ff8-0310-8827-fb3f25b6796d --- diff --git a/lib/Devel/REPL/Plugin/Nopaste.pm b/lib/Devel/REPL/Plugin/Nopaste.pm index 19e30ae..7bd925e 100644 --- a/lib/Devel/REPL/Plugin/Nopaste.pm +++ b/lib/Devel/REPL/Plugin/Nopaste.pm @@ -16,21 +16,24 @@ has complete_session => ( }, ); -around eval => sub { - my $orig = shift; +before eval => sub { my $self = shift; my $line = shift; - my @ret = $orig->($self, $line, @_); - # prepend each line with # $line =~ s/^/# /mg; - my $step = $line . "\n" - . join("\n", @ret) - . "\n\n"; + $self->add_to_session($line . "\n"); +}; + +around eval => sub { + my $orig = shift; + my $self = shift; + my $line = shift; + + my @ret = $orig->($self, $line, @_); - $self->add_to_session($step); + $self->add_to_session(join("\n", @ret) . "\n\n"); return @ret; };