Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Re: Re: Re: Re: Re: Surpised by foreach iterator limitation

by Anonymous Monk
on Apr 08, 2003 at 04:34 UTC ( #248813=note: print w/replies, xml ) Need Help??

in reply to Re: Re: Re: Re: Re: Surpised by foreach iterator limitation
in thread Surpised by foreach iterator limitation

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.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://248813]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2021-09-20 01:45 GMT
Find Nodes?
    Voting Booth?

    No recent polls found