develooper Front page | perl.perl5.porters | Postings from May 2004

Re: ++(my $x = {}) [Was: Re: my $x->{foo} doesn't work]

Thread Previous | Thread Next
From:
Ronald J Kimball
Date:
May 21, 2004 12:36
Subject:
Re: ++(my $x = {}) [Was: Re: my $x->{foo} doesn't work]
Message ID:
20040521193642.GA61272@penkwe.pair.com
On Sat, May 22, 2004 at 04:25:43AM +0900, Dan Kogai wrote:

> Hey, watch this!
> 
> >% perl -le 'my $x=42; $x->[0]=3.14; print $x; print $x->[0]; print 
> >ref($x)'
> >42
> >3.14
> >
> >% perl -le 'my $x; $x->[0] = 3.14; print $x; print $x->[0]; print 
> >ref($x)'
> >ARRAY(0x801180)
> >3.14
> >ARRAY
> 
> See the difference?  The first one has 42 assigned a priori.  I have 
> duplicated this even on good old 5.00503, not to mention 5.8.4.
> 

Maybe you should try that again with use strict.

Ronald

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