#!/usr/bin/perl $sel = $ARGV[0]; shift @ARGV; for (@ARGV) { $s = 0; $n = 0; open(FILE, $_) || die "$_: $!"; while () { $c = 0 if //; if (/]*>([0-9.]+)/ ) { $c++; next unless $c == $sel; $s += $1; $n++; } } close FILE; print "$s/$n = ", $s/$n, "\n"; }