Eric Roode on 13 Dec 2004 01:01:09 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: perldb weirdness


No, you have two different references to the same array.  This line:

    $unique_sets{$sets{$s}} = $sets{$s};

makes a copy of the reference, not a copy of the array to which the reference
points.

HTH

Quoting Jeff Abrahamson <jeff@purple.com>:

> Notice how I appear to have two different arrays with base address
> 0x8522038.  Does this make sense to anyone here?
> 
>       DB<64> @k=keys %unique_sets
> 
>       DB<65> $k=$k[0]
> 
>       DB<66> x $k
>     0  'ARRAY(0x8522038)'
>       DB<67> x $sets{$s}
>     0  ARRAY(0x8522038)
>        0  'jpw'
>       DB<68> x @{$k}
>       empty array
>       DB<69> x $unique_sets{$k}
>     0  ARRAY(0x8522038)
>        0  'jpw'
>       DB<70> 
> 
> A snippet of the underlying code is this:
> 
>     my %unique_sets;
>     for my $s (keys %sets) {
> 	print $sets{$s}, "\n";
> 	$unique_sets{$sets{$s}} = $sets{$s};
> 	print $sets{$s}, "\n";
>     }
> 
> -- 
>  Jeff
> 
>  Jeff Abrahamson  <http://www.purple.com/jeff/>    +1 215/837-2287
>  GPG fingerprint: 1A1A BA95 D082 A558 A276  63C6 16BF 8C4C 0D1D AE4B
> 
>  A cool book of games, highly worth checking out:
>  http://www.amazon.com/exec/obidos/ASIN/1931686963/purple-20
> 


-- 
Eric

___________________________________________________________________

Privacy Notice: This message has been sent via www.zoemail.net using
patented e-mail protection technology developed by AT&T Labs. Reply to
the "keyed address" above to ensure delivery.

-
**Majordomo list services provided by PANIX <URL:http://www.panix.com>**
**To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**