#!/usr/bin/perl # Ivan Novick # autovivification.pl # demonstrate perl's autovivification use strict; use warnings; # x is not defined my $x = undef; print "$x\n" if $x; # autovivification occurs here # perl will create a hash in memory and assign the address to scalar $x $x->{'foo'} = 3; # x now contains to a valid memory address of a HASH print "$x\n"; # the value 3 should be printed print "$x->{'foo'}\n";