Hello, I continue to have difficulties using hashes.
I have a hash that I am storing arrays in. Each array corresponds to one hour of a
day. After the hash has been populated I need to cycle through the "days" and sum
them up. So, I have written my hash such that each key can be looped thru via a for
loop.
My keys are simply data.hr1, data.hr2, data.hr3, where each key is incremented via the
for loop. The problem seems to be that when I use $specSum{$name}[$i] where $name
would be data.hr1, data.hr2, data.hr3 ... it doesnt work. How can I use a variable as
a key to a hash? My code works just fine when I write $specSum{'data.hr1'}[$i]. A
snippet of my code is pasted below. Thanks for the help.
Cheers, Tyler.
for(local $b=0; $b<=23; $b++){
local $hour = $b+1;
local $root = 'data.hr';
local $name = "$root$hour";
for(local $i=0; $i<=1847; $i++){
$specSum{$name}[$i] = $specSum{$name}[$i] + $hrHash{$name}[$i];
}
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]