1 package Eval::WithLexicals::WithHintPersistence;
13 default => sub { {} },
20 local *Eval::WithLexicals::Cage::capture_hints;
21 local $Eval::WithLexicals::Cage::hints = { %{$self->hints} };
23 my @ret = $orig->(@_);
25 $self->hints({ Eval::WithLexicals::Cage::capture_hints() });
30 # XXX: Sub::Quote::capture_unroll without 'my'
32 sub _capture_unroll_global {
33 my ($from, $captures, $indent) = @_;
38 or die "capture key should start with \@, \% or \$: $_";
39 (' ' x $indent).qq{${_} = ${1}{${from}->{${\B::perlstring $_}}};\n};
46 # Only run the prelude on the first eval, hints will be set after
48 if($self->first_eval) {
50 return $self->prelude;
52 # Seems we can't use the technique of passing via @_ for code in a BEGIN
55 _capture_unroll_global('$Eval::WithLexicals::Cage::hints', $self->hints, 2),
60 around capture_code => sub {
64 ( q{ sub Eval::WithLexicals::Cage::capture_hints {
65 no warnings 'closure'; # XXX: can we limit the scope of this?
67 BEGIN { $hints = $^H; %hints = %^H; }
68 return q{$^H} => \$hints, q{%^H} => \%hints;