develooper Front page | perl.perl5.porters | Postings from March 2000

Exotic bug in local?

Thread Previous | Thread Next
From:
Tom Christiansen
Date:
March 22, 2000 21:00
Subject:
Exotic bug in local?
Message ID:
14407.953787615@chthon
From perlsub:

    If more than one variable is given to C<local>, they must be
    placed in parentheses.  All listed elements must be legal
    lvalues.  This operator works by saving the current values of
    those variables in its argument list on a hidden stack and
    restoring them upon exiting the block, subroutine, or eval.

This one only half-works, though:  

    % perl -le '@a = 1..10; { local $#a = 4; print @a; } print @a'
    12345
    12345

Ok, so it's totally nuts, but it seems like it *tries* to work but
then forgets to undo the local.  Operators shouldn't be teases.
They should say yes or no and be done with it, not get you halfway
to happiness and then wander off. :-)

--tom

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About