push @{$r{join ' ' x 8, @F[0..3]};}, [@F[4, 6]]; { foreach my $k (keys %r) { my($x, $y); print "\$r{\$k};", $r{$k}; print "\@{\$r{\$k};}", @{$r{$k};}; map {$x += $$_[0]; $y += $$_[1]; print "\$_='$_'", "SS_[0]=$$_[0]", "SS_[1]=$$_[1]", "x=$x", "y=$y"; } @{$r{$k};}; my @g = split(/\s+/,$k); print OUT "$g[0]\t@g[1]\t@g[2]\t@g[3]\t", $x / scalar(@{$r{$k};}), "\t$y\n"; } } #### $k; # == "1 136 G A" with more spaces $r{$k}; # == [ [1,6], [1,9] ] == referenece to an array of array-refs @{$r{$k}}; # == ( [1,6], [1,9] ) == array of array-refs map {} @ # for each element in the @ array, run the {} block # First element of @ is the first ref to a pair-array: $_; # = [1,6] == array ref $$_; # = (1,6) == array $$_[0]; # = 1 == first element of array (1,6) or arrayref [1,6] $$_[1]; # = 6 # Second element of @ is the next ref to a pair-array $_; # = [1,9] $$_[0]; # 1 $$_[1]; # 9