my $package = $self->in_package;
my $setup_code = join '', $self->setup_code,
+ # $_[2] being what is passed to _eval_do below
Sub::Quote::capture_unroll('$_[2]', $self->lexicals, 2);
my $capture_code = join '', $self->capture_code;
%{$self->lexicals},
%{$self->_grab_captures},
});
- @ret;
+ return $self->context eq 'list' ? @ret : $ret[0];
}
sub _grab_captures {
use Eval::WithLexicals;
use Term::ReadLine;
use Data::Dumper;
+ use Getopt::Long;
+
+ GetOptions(
+ "plugin=s" => \my @plugins
+ );
$SIG{INT} = sub { warn "SIGINT\n" };
$Quotekeys = 0;
}
- my $eval = Eval::WithLexicals->new;
+ my $eval = @plugins
+ ? Eval::WithLexicals->with_plugins(@plugins)->new
+ : Eval::WithLexicals->new;
+
my $read = Term::ReadLine->new('Perl REPL');
while (1) {
my $line = $read->readline('re.pl$ ');
$eval->prelude(q{use warnings}); # only warnings, not strict.
+=head2 with_plugins
+
+ my $eval = Eval::WithLexicals->with_plugins("HintPersistence")->new;
+
+Construct a class with the given plugins. Plugins are roles located under
+a package name like C<Eval::WithLexicals::With*>.
+
+Current plugins are:
+
+=over 4
+
+=item * HintPersistence
+
+When enabled this will persist pragams and other compile hints between evals
+(for example the L<strict> and L<warnings> flags in effect). See
+L<Eval::WithLexicals::WithHintPersistence> for further details.
+
+=back
+
=head1 AUTHOR
Matt S. Trout <mst@shadowcat.co.uk>