----- Original Message ----- 
From: "Craig Moynes/Markham/IBM" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, July 12, 2002 2:48 PM
Subject: anonymous reference problems


> 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

If $tmpEntry{'StartDate'} is ever repeated, you will always over write the date that 
was in that hash key...
if you are wanting multiple entries for any key, do a push like so:
  push @{$oncall{$tmpEntry{'StartDate'}}}, \%tmpEntry;

This will make a referenced array of hashes that you can iterate over...

Shawn


> reference to the memory location.
> 
> I need something similar ...I thought about taking each value of tmpEntry
> and setting each variable like so:
> $oncall{$tmpEntry{'StartDate'}}->{x} = $tmpEntry{x};
> $oncall{$tmpEntry{'StartDate'}}->{y} = $tmpEntry{y};
> 
> but that seem inelegant at best.
> 
> Thoughts ?
> 
> -----------------------------------------
> Craig Moynes
> [EMAIL PROTECTED]
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 


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

Reply via email to