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

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

Thread Previous
From:
Dave Mitchell
Date:
October 29, 2003 01:55
Subject:
Re: [perl #24342] Coredump when shortening an array during use
Message ID:
20031029095536.GA18675@fdgroup.com
On Wed, Oct 29, 2003 at 09:58:02AM +0100, Rafael Garcia-Suarez wrote:
> Going to answer my own question :
> > 
> > Could someone explain why this is allowed at all ?
> > Why can I apply -= to an array slice but not to an array ?
> 
> Hm, probably for compatibility with the (mistaken) use
> of a one-element slice as an array element.
> 
> 	@x[2] -= 3;

Surely its just the normal 'last element returned' behaviour of a list in
scalar context, eg

$ perl5.8.1 -le'$a=1;$b=2;($a,$b)+=10; print "$a $b"'
1 12
$ perl5.8.1 -le'$a=1;$b=2;@c=(($a,$b)+=10); print "$a $b; @c"'
1 12; 12



-- 
You live and learn (although usually you just live).

Thread Previous


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