+ - Make prelude configurable, so strictures can be optional
+
1.1.0 2011-01-11 25:51:00
- Add a #line directive so it's clearer where errors occurred (DGL)
- Filter out lexicals called '&' since these are anon subs (MSTROUT)
is => 'rw', default => quote_sub q{ 'Eval::WithLexicals::Scratchpad' }
);
+has prelude => (
+ is => 'rw', default => quote_sub q{ 'use strictures 1;' }
+);
+
sub eval {
my ($self, $to_eval) = @_;
local *Eval::WithLexicals::Cage::current_line;
local *Eval::WithLexicals::Cage::grab_captures;
my $setup = Sub::Quote::capture_unroll('$_[2]', $self->lexicals, 2);
my $package = $self->in_package;
- local our $current_code = qq!use strictures 1;
+ my $prelude = $self->prelude;
+ local our $current_code = qq!${prelude}
${setup}
sub Eval::WithLexicals::Cage::current_line {
package ${package};
lexicals => { '$x' => \1 }, # default {}
in_package => 'PackageToEvalIn', # default Eval::WithLexicals::Scratchpad
context => 'scalar', # default 'list'
+ prelude => 'use warnings', # default 'use strictures 1'
);
=head2 eval
$eval->context($new_context); # 'list', 'scalar' or 'void'
+=head2 prelude
+
+Code to run before evaling code. Loads L<strictures> by default.
+
+ my $current_prelude = $eval->prelude;
+
+ $eval->prelude(q{use warnings}); # only warnings, not strict.
+
=head1 AUTHOR
Matt S. Trout <mst@shadowcat.co.uk>