in reply to take 'n' array elements at a time

Hi fionbarr,

Here is one possible way:

use strict; my $n = 2; my $cnt; my $sum; while(<>) { chomp; $cnt++; my (undef, $v) = split(/\|/); $sum += $v; print "cnt: $cnt v: $v sum: $sum\n"; if (($cnt % $n) == 0) { print "avg: " . $sum / $n . "\n";; $sum = 0 ; } }
You can use 'perldoc -f glob' or shell commands to redirect all the input data to stdin.