[Omaha.pm] Fun w/ autovivification
Jay Hannah
jhannah at omnihotels.com
Mon Apr 17 13:39:47 PDT 2006
$ cat j.pl
my $a = {};
# This should fail:
check();
# And doing this has no effect:
my $j = $$a{1};
check();
# But once we do this $$a{1} magically springs into existence...
my $j = $$a{1}{2};
check();
sub check {
if (exists $$a{1}) {
print "yup\n";
} else {
print "nope\n";
}
}
$ perl j.pl
nope
nope
yup
More info: http://en.wikipedia.org/wiki/Autovivification
j
More information about the Omaha-pm
mailing list