1 package Eval::WithLexicals::WithHintPersistence;
5 our $VERSION = '1.002000'; # 1.2.0
6 $VERSION = eval $VERSION;
10 default => quote_sub q{ {} },
17 local *Eval::WithLexicals::Cage::capture_hints;
18 local $Eval::WithLexicals::Cage::hints = { %{$self->hints} };
20 my @ret = $orig->(@_);
22 $self->hints({ Eval::WithLexicals::Cage::capture_hints() });
24 join '', q[ BEGIN { ],
25 _capture_unroll_global('$Eval::WithLexicals::Cage::hints', $self->hints, 2),
32 # XXX: Sub::Quote::capture_unroll without 'my'
34 sub _capture_unroll_global {
35 my ($from, $captures, $indent) = @_;
40 or die "capture key should start with \@, \% or \$: $_";
41 (' ' x $indent).qq{${_} = ${1}{${from}->{${\B::perlstring $_}}};\n};
46 around capture_code => sub {
50 ( q{ sub Eval::WithLexicals::Cage::capture_hints {
51 my ($hints, %hints, $warn_bits);
53 no warnings 'closure';
56 $warn_bits = ${^WARNING_BITS};
61 q{${^WARNING_BITS}} => \$warn_bits,
72 Eval::WithLexicals::WithHintPersistence - Persist compile hints between evals
76 use Eval::WithLexicals;
78 my $eval = Eval::WithLexicals->with_plugins("HintPersistence")->new;
82 Persist pragams and other compile hints between evals (for example the
83 L<strict> and L<warnings> flags in effect).
85 Saves and restores the C<$^H> and C<%^H> variables.
93 Returns the internal hints hash, keys are C<$^H> and C<%^H> for the hint bits
94 and hint hash respectively.
98 See L<Eval::WithLexicals> for support and contact information.
102 See L<Eval::WithLexicals> for authors.
104 =head1 COPYRIGHT AND LICENSE
106 See L<Eval::WithLexicals> for the copyright and license.