O wise perl monks,
please grant me the benefit of your advice:
Investigating a bizarre problem today, I found some anomalous behaviour in perl.
use Data::Dumper qw(Dumper); my $data = { args => '', }; $data->{args}->{stuff} = 'bother'; print Dumper($data); print "The value is ", $data->{args}->{stuff}, "\n";
The script outputs:
$VAR1 = { 'args' => '' }; The value is bother
Now, "$data->{args}" has been initialised to a scalar empty string. Without using "use strict", perl allows code which treats this like a hashref and stores something in it. The stored data (in this case, a hashref with key stuff and value bother) can't be seen by Data::Dumper but can be retrieved in the same way it was stored.
Is this a perl bug? If I "use strict" then my program emits an error.
Is this a language feature? I have checked this behaviour in perl 5.6, 5.8 and 5.10. Is it something to do with symbolic references ala "use strict refs" ?
In reply to The hidden hashref by nickandrew
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |