in reply to Making a hash of making a hash of an array
I believe the logic in your for loop is incorrect, beside kabel's point about wrecking your hash by assigning to it after the loop, the while loop inside the for simply ends up assigning each line of the file to the hash 10 times
foreach my $line (@record) { ($timestamp, $current_time, $funds, $action, $current_funds) = split " +\t",$line; # The values of $timestamp, $current_time, $funds, $action, $current_f +unds never change in this while loop. while ($count < 10){ $member{$timestamp} = [$current_time, $funds, $action, $current_fu +nds]; $count += 1; } }
You want something like this:
for my $line (@record[0..9]) { ($timestamp, $current_time, $funds, $action, $current_funds) = split + "\t",$line; $member{$timestamp} = [$current_time, $funds, $action, $current_fund +s]; }
HTH
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Making a hash of making a hash of an array
by jonnyfolk (Vicar) on Jun 04, 2003 at 05:33 UTC | |
by pzbagel (Chaplain) on Jun 04, 2003 at 07:16 UTC | |
by jonnyfolk (Vicar) on Jun 04, 2003 at 10:52 UTC | |
by jeffa (Bishop) on Jun 04, 2003 at 14:01 UTC |