develooper Front page | perl.perl5.porters | Postings from October 2003

Re: [perl #24342] Coredump when shortening an array during use

Thread Previous | Thread Next
From:
Rafael Garcia-Suarez
Date:
October 29, 2003 00:20
Subject:
Re: [perl #24342] Coredump when shortening an array during use
Message ID:
20031029091351.2420e2cc.rgarciasuarez@free.fr
perl-5.8.0@ton.iguana.be (via RT) wrote:
> perl -wle '$a=@F[4,7]-=@F=3'
> Segmentation fault (core dumped)

Could someone explain why this is allowed at all ?
Why can I apply -= to an array slice but not to an array ?

    $ ./perl -wle '@x=(1..5);@x[1,2]-=3;print for@x'
    1
    2
    0
    4
    5

    $ ./perl -wle '@x=(1..5);@x-=3;print for@x'
    Can't modify array dereference in subtraction (-) at -e line 1, near "3;"
    Execution of -e aborted due to compilation errors.


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