http://qs321.pair.com?node_id=691575


in reply to Explaining Autovivication

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...