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

Re: Exotic bug in local?

Thread Previous | Thread Next
From:
Tom Christiansen
Date:
March 22, 2000 21:02
Subject:
Re: Exotic bug in local?
Message ID:
19827.953787757@chthon
PS:

>    % 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().

--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