1 package Eval::WithLexicals::WithHintPersistence;
5 our $VERSION = '1.003006'; # v1.3.6
6 $VERSION = eval $VERSION;
10 default => quote_sub q{ {} },
15 default => quote_sub q{ 1 },
22 local *Eval::WithLexicals::Cage::capture_hints;
23 local $Eval::WithLexicals::Cage::hints = { %{$self->hints} };
25 my @ret = $orig->(@_);
27 $self->hints({ Eval::WithLexicals::Cage::capture_hints() });
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};
48 # Only run the prelude on the first eval, hints will be set after
50 if($self->_first_eval) {
51 $self->_first_eval(0);
52 return $self->prelude;
54 # Seems we can't use the technique of passing via @_ for code in a BEGIN
57 _capture_unroll_global('$Eval::WithLexicals::Cage::hints', $self->hints, 2),
62 around capture_code => sub {
66 ( q{ sub Eval::WithLexicals::Cage::capture_hints {
67 my ($hints, %hints, $warn_bits);
69 no warnings 'closure';
72 $warn_bits = ${^WARNING_BITS};
77 q{${^WARNING_BITS}} => \$warn_bits,
88 Eval::WithLexicals::WithHintPersistence - Persist compile hints between evals
92 use Eval::WithLexicals;
94 my $eval = Eval::WithLexicals->with_plugins("HintPersistence")->new;
98 Persist pragams and other compile hints between evals (for example the
99 L<strict> and L<warnings> flags in effect).
101 Saves and restores the C<$^H> and C<%^H> variables.
109 Returns the internal hints hash, keys are C<$^H> and C<%^H> for the hint bits
110 and hint hash respectively.
114 See L<Eval::WithLexicals> for support and contact information.
118 See L<Eval::WithLexicals> for authors.
120 =head1 COPYRIGHT AND LICENSE
122 See L<Eval::WithLexicals> for the copyright and license.