I think you are confusing yourself with arbitrary distinctions of exactly the kind that Perl cheerfully tramples over.

By your reasoning I would predict that local should not work on a hash value - because local replaces a scalar with another scalar temporarily. But lo and behold, look at this!

use Data::Dumper; %foo = qw(hello world); print Dumper \%foo; { local $foo{test} = "Just for now"; print Dumper \%foo; } print Dumper \%foo;
What happened? Well take your pick. Either Perl doesn't agree with your distinction between "valid syntax to name an element of a collective" and "valid syntax for a scalar name" or else Perl is sometimes unusually willing to accept the former in places where one would expect the latter. (I lean towards the second interpretation - after all one cannot use my just anywhere, nor can one get that to make any sense.)

Therefore if someone is willing to do the work and there is no ambiguity in the parsing, this feature could make it into Perl 5 and it wouldn't necessarily be a bad thing.

Incidental note. One cannot use local on a lexical. This is an utterly arbitrary limitation - the feature was once put in only to be taken out because it was felt that where it happened it was undoubtably a mistake.


In reply to Re: Re: Re: Re: Re: Re: Surpised by foreach iterator limitation by Anonymous Monk
in thread Surpised by foreach iterator limitation by shotgunefx

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.