in reply to Re: Generating a list of numbers from other lists
in thread Generating a list of numbers from other lists
Just in case the OP ever wants to process tens of megabytes that way :)my (%result, %sums); while (<DATA>) { chomp; my ($first, $second) = split; if ($numberHash{$first}) { push @{$result{$first}}, $second; $sums{$first}+= $second; } } foreach my $first (sort { $a <=> $b } keys %result) { foreach my $second (@{$result{$first}}) { print "$first $second $sums{$first}\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Generating a list of numbers from other lists
by Marshall (Canon) on Jan 29, 2012 at 18:45 UTC |