Re: perl syntax oddity

Rafael Garcia-Suarez <[email protected]>
Newsgroups gmane.comp.lang.perl.fun
Message-ID <[email protected]>
Yitzchak Scott-Thoennes wrote in perl.fwp :
>> 
>>   sub getaglob {*foo}
>>   $foo = "pong\n";
>>   { local ${&getaglob} = "ping "; print $foo }
>>   print $foo;
>> 
>> fails with "Can't localize through a reference"!
> 
> This error seems to be removed in 5.8.1 and it works there (though the
> error entry was erroneously left in perldiag).

perldiag is still correct, because this error was only removed in some
cases.  Perl 5.8.1 allows localization through a symbolic reference, but
not a hard one :

    $ bleadperl -le '$x="a";local $$x=2;print$a,$$x'
    22

    $ bleadperl -le '$x=\"a";local $$x=2;print$$x'
    Can't localize through a reference at -e line 1.

-- 
If strain on the lexer were a design criterion, I blew it long ago.
    -- Larry Wall
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.