Just another example of where Perl automagically creates data structures as needed:
#!/usr/bin/perl use strict; use warnings; my $href; # not initialized for my $key (keys %$href) { # ... do something } use Data::Dumper; print Dumper $href; # --> $VAR1 = {};
which shows that $href has been autovivified to hold a reference to an (empty) hash, simply because you were using the scalar in a way (keys %$href) that would not have worked without such a data structure...
In reply to Re: Explaining Autovivication
by almut
in thread Explaining Autovivication
by perly-gates
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |