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:

my %h; { local $h{a}{b} = 1; } use Data::Dumper; print Dumper(\%h);
which shows that while $h{a}{b} has gone away, $h{a} still exists as an empty hashref.

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


In reply to Re: Perl 5.6 vs. 5.8: 'local' behaviour difference by hv
in thread Perl 5.6 vs. 5.8: 'local' behaviour difference by calin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.