in reply to Re^5: Keys() required to autovivify?
in thread Keys() required to autovivify?
Output:#!/usr/bin/perl my %h; my $val = $h{x}{y}; use Data::Dumper; print Dumper \%h;
Apparently, not only does $h{x} not autovivify $h{x}, but even %{$h{x}} does not autovivify $h{x} (you have to turn off strict and -w first):$VAR1 = { 'x' => {} };
Output:#!/usr/bin/perl my %h; %{$h{x}}; use Data::Dumper; print Dumper \%h;
But, using keys() causes %{$h[x}} to autovivify $h{x}.$VAR1 = {};
Output:#!/usr/bin/perl -w use strict; my %h; keys %{$h{x}}; use Data::Dumper; print Dumper \%h;
$VAR1 = { 'x' => {} };
|
|---|