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 no warnings 'closure';
72 BEGIN { $hints = $^H; %hints = %^H; }
73 return q{$^H} => \$hints, q{%^H} => \%hints;
83 Eval::WithLexicals::WithHintPersistence - Persist compile hints between evals
87 use Eval::WithLexicals;
89 my $eval = Eval::WithLexicals->with_plugins("HintPersistence")->new;
93 Persist pragams and other compile hints between evals (for example the
94 L<strict> and L<warnings> flags in effect).
96 Saves and restores the C<$^H> and C<%^H> variables.
104 Returns the internal hints hash, keys are C<$^H> and C<%^H> for the hint bits
105 and hint hash respectively.
109 See L<Eval::WithLexicals> for support and contact information.
113 See L<Eval::WithLexicals> for authors.
115 =head1 COPYRIGHT AND LICENSE
117 See L<Eval::WithLexicals> for the copyright and license.