Hello!
Here is the program, and below results for perl 5.24 and 5.28:
#!/usr/bin/perl -CSDA
use utf8;
use Modern::Perl qw{2017};
no autovivification qw{fetch store exists delete};
my $h = {
'a' => {
'p' => 2,
'q' => 3,
},
};
print "perl ver $]:\n";
$$h{a} and print "a ok\n";
! $$h{b} and print "b not\n";
! $$h{a}{x} and print "a/x not\n";
! $$h{a}{x}{z} and print "a/x/z not\n";
perl ver 5.024001:
a ok
b not
a/x not
a/x/z not
perl ver 5.028001:
a ok
b not
a/x not
Can't vivify reference at ./atest line 18.
Could someone please explain what has changed between 5.24 and 5.28 in regard of autovivification? And what would be the proper way to check existence of value in last line in ver 5.28?
ver 5.24 good way:
! $$h{a}{x}{z} and print "a/x/z not\n";
ver 5.28 good (?) way:
! ( $$h{a} && $$h{a}{$x} && $$h{a}{x}{z}) and print "a/x/z not\n"; #
+ ?? any better idea?
PS. I have to prevent perl from modifying my data structure "behind the scenes", because that structures get mapped to textual data that goes to manufacturing management system, and if any undef is inside data structure then error is thrown, because that means that someone made something wrong.