in reply to Re: Using Data::Dumper with a HoH
in thread Using Data::Dumper with a HoH
I was first thinking of another pitfall you have to watch out for, at least with strict off, and that is when while populating the hash, some entries may not be a ref or undef, but a string. In that case, Perl will go weird on you. For example:
which produces:use Data::Dumper; no strict; %hash = ( a => 'x123' ); $hash{a}{b} = 'data'; print Dumper \%hash;
So, where did your data go to? It went into the global variable %x123, via a symbolic reference ${$hash{$a}}{b}.$VAR1 = { 'a' => 'x123' };
producesprint Dumper \%hash, \%x123;
The "used only once" warning is a compile time warning, but using the symbolic reference (once) doesn't produce any warnings at all.Name "main::x123" used only once: possible typo at Z:\test.pl line 6. $VAR1 = { 'a' => 'x123' }; $VAR2 = { 'b' => 'data' };
|
|---|