1 package Eval::WithLexicals::WithHintPersistence;
5 our $VERSION = '1.001000'; # 1.1.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;
80 Eval::WithLexicals::WithHintPersistence - Persist compile hints between evals
84 use Eval::WithLexicals;
86 my $eval = Eval::WithLexicals->with_plugins("HintPersistence")->new;
90 Persist pragams and other compile hints between evals (for example the
91 L<strict> and L<warnings> flags in effect).
93 Saves and restores the C<$^H> and C<%^H> variables.
101 Returns the internal hints hash, keys are C<$^H> and C<%^H> for the hint bits
102 and hint hash respectively.