1 package Eval::WithLexicals::WithHintPersistence;
5 our $VERSION = '1.002000'; # 1.2.0
6 $VERSION = eval $VERSION;
13 default => quote_sub q{ {} },
18 default => quote_sub q{ 1 },
25 local *Eval::WithLexicals::Cage::capture_hints;
26 local $Eval::WithLexicals::Cage::hints = { %{$self->hints} };
28 my @ret = $orig->(@_);
30 $self->hints({ Eval::WithLexicals::Cage::capture_hints() });
35 # XXX: Sub::Quote::capture_unroll without 'my'
37 sub _capture_unroll_global {
38 my ($from, $captures, $indent) = @_;
43 or die "capture key should start with \@, \% or \$: $_";
44 (' ' x $indent).qq{${_} = ${1}{${from}->{${\B::perlstring $_}}};\n};
51 # Only run the prelude on the first eval, hints will be set after
53 if($self->_first_eval) {
54 $self->_first_eval(0);
55 return $self->prelude;
57 # Seems we can't use the technique of passing via @_ for code in a BEGIN
60 _capture_unroll_global('$Eval::WithLexicals::Cage::hints', $self->hints, 2),
65 around capture_code => sub {
69 ( q{ sub Eval::WithLexicals::Cage::capture_hints {
70 my ($hints, %hints, $warn_bits);
72 no warnings 'closure';
75 $warn_bits = ${^WARNING_BITS};
80 q{${^WARNING_BITS}} => \$warn_bits,
91 Eval::WithLexicals::WithHintPersistence - Persist compile hints between evals
95 use Eval::WithLexicals;
97 my $eval = Eval::WithLexicals->with_plugins("HintPersistence")->new;
101 Persist pragams and other compile hints between evals (for example the
102 L<strict> and L<warnings> flags in effect).
104 Saves and restores the C<$^H> and C<%^H> variables.
112 Returns the internal hints hash, keys are C<$^H> and C<%^H> for the hint bits
113 and hint hash respectively.
117 See L<Eval::WithLexicals> for support and contact information.
121 See L<Eval::WithLexicals> for authors.
123 =head1 COPYRIGHT AND LICENSE
125 See L<Eval::WithLexicals> for the copyright and license.