On Fri, 2002-07-12 at 15:48, Craig Moynes/Markham/IBM wrote:
> 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.
> 
> 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]
> 

<example>
#!/usr/bin/perl -w
use strict;

use Data::Dumper;

my %hash = (
        this => 10,
        that => 20
);

my %HoH;

$HoH{one} = {
        %hash
};

@hash{'this','that'} = (50,100);

$HoH{two} = {
        %hash
};

print Dumper(\%HoH);
</example>

-- 
Today is Pungenday the 47th day of Confusion in the YOLD 3168
Wibble.

Missile Address: 33:48:3.521N  84:23:34.786W


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

Reply via email to