Hey Jeff,
> >I have a loop, each iteration through the loop the hash %tmpEntry gets a
> >new set of values. And each iteration through the loop I place this hash
> >into another hash, like so:
> >
> >[snip]
> > print "Added entry.\n";
> >$oncall{$tmpEntry{'StartDate'}} =  \%tmpEntry;
> >[snip]
> >
> >tmpEntry is defined outside the loop, because I need to handle the last
> >case outside of the loop. This doesn't work, all the entries end up
> >being the same, because of the reference to the memory location.
> 
> You'll need to use { %tmpEntry } then, instead of \%tmpEntry.

Can you explain the difference between the anonymous hash and the referenced hash, and 
why it would make a difference here?

Is it because the anonymous scalar reference does not keep the same memory space?

I guess my question is: aren't these two equal statements?

  my $hash=\%tmpEntry;
  my $hash={ %tmpEntry };

This is what I get from the command line:

>perl -e "%hash=(1=>'one',2=>'two'); my $hash=\%hash; print $hash,qq~\n~; 
>$hash={%hash}; print $hash,qq~\n~;"
HASH(0x1ac2db8)
HASH(0x1acf150)

>perl -e "%hash=(1=>'one',2=>'two'); my $hash=\%hash; print %$hash,qq~\n~; 
>$hash={%hash}; print %$hash,qq~\n~;"
1one2two
1one2two

Shawn


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to