in reply to Perl 5.6 vs. 5.8: 'local' behaviour difference
The keyword here is "autovivification", which is the jargon word used within the perl community to describe situations in which something referred to without explicitly being created is caused to spring into existence. Knowing that word may help you to search for and understand more of the history of this particular change and how it might change in the future.
One possible way that behaviour might change in the future is to extend the 5.8.0 fix to deeper structures:
which shows that while $h{a}{b} has gone away, $h{a} still exists as an empty hashref.my %h; { local $h{a}{b} = 1; } use Data::Dumper; print Dumper(\%h);
For the second question, I can assure you that your use of hash slices in local and delete is perfectly legal and will not be going away. The key phrase of the brief documentation in perlfunc is A local modifies the listed variables ... - the hash slice is providing such a list of variables, and each of those variables is individually being localised.
It is however confusing that it goes on to say that the list must be parenthesised if more than one variable is listed - a single hash or array slice is an exception to that rule.
Hugo
|
|---|