There is much good advice and learning throughout the thread... to sum up what my recommendations would be
foreach my $pair_ref ( @{ $r{$k} } ) { # for each [col4,col6] pai +r that matched on the four-column key my ($col4, $col6) = @$pair_ref; # get the (col4,col6) valu +es $x += $col4; # x is the summation of al +l the matching col4 values $y += $col6; # similar for y }
1 I know for many non-expert Perl coders, the explicit join is more natural and possibly easier to remember in the future than the magic variables; personally, despite having hacked Perl for ... eek, two decades now! -- it wasn't until I started really frequenting perlmonks a few months back that I actually understood what the $, and $" variables do, and started using them
In reply to Re: Code clarification - use of map and $$_
by pryrt
in thread Code clarification - use of map and $$_
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |