+ - Filter out lexicals called '&' since these are anon subs
+
1.0.0 2010-12-05 17:04:00
- Initial release (MSTROUT)
sub capture_list {
my $pad_capture = \&Eval::WithLexicals::Cage::pad_capture;
- my @names = map $_->PV, grep $_->isa('B::PV'),
+ my @names = grep $_ ne '&', map $_->PV, grep $_->isa('B::PV'),
svref_2object($pad_capture)->OUTSIDE->PADLIST->ARRAYelt(0)->ARRAY;
$Eval::WithLexicals::current_code .=
'+{ '.join(', ', map "'$_' => \\$_", @names).' };'
'No capture of invisible $y'
);
+$eval->eval('my $y = sub { $_[0]+1 }');
+
+is_deeply(
+ [ $eval->eval('$y->(2)') ],
+ [ 3 ],
+ 'Sub created ok'
+);
+
done_testing;