Undefined values in the hint hash were being deparsed as empty
strings. Whenever the hint hash changed, all undefined values, even
those unmodified, were being printed.
my @decls;
for my $key (keys %$to) {
next if $ignored_hints{$key};
- if (!defined $from->{$key} or $from->{$key} ne $to->{$key}) {
- push @decls, qq(\$^H{'$key'} = q($to->{$key}););
+ if (!exists $from->{$key} or $from->{$key} ne $to->{$key}) {
+ push @decls, qq(\$^H{'$key'} = )
+ . (defined $to->{$key} ? qq(q($to->{$key})) : 'undef')
+ . qq(;);
}
}
for my $key (keys %$from) {
# substr assignment
substr(my $a, 0, 0) = (foo(), bar());
$a++;
+####
+# hint hash
+BEGIN { $^H{'foo'} = undef; }
+{
+ BEGIN { $^H{'bar'} = undef; }
+ {
+ BEGIN { $^H{'baz'} = undef; }
+ {
+ print $_;
+ }
+ print $_;
+ }
+ print $_;
+}