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

Re: Exotic bug in local?

Thread Previous | Thread Next
Tom Christiansen
March 22, 2000 21:02
Re: Exotic bug in local?
Message ID:

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

    Assigning to `$#days' actually changes the length of the array.
    Shortening an array this way destroys intervening values.
    Lengthening an array that was previously shortened does not
    recover values that were in those elements.

I can understand that it destroys them if you say

    $#a = 4;

But I don't understand why it pretends not have seen the local().


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