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

Exotic bug in local?

Thread Previous | Thread Next
Tom Christiansen
March 22, 2000 21:00
Exotic bug in local?
Message ID:
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'

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. :-)


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About