Eu lidaria com algo assim:
#!/usr/bin/perl
use warnings;
use strict;
my $field_count = 3;
#discard first row, as the fields don't match
my $first_row = <>;
#iterate STDIN or files specified on command line, just like grep or sed do.
while ( <> ) {
#extract the name and values. Maybe you need a 'chomp' to remove linefeeds
#it works given your sample data, because the last field is a number.
my ( $samplename, @fields ) = split;
my @new_fields;
while ( @fields ) {
#extract fields 3 at a time.
my @group = splice @fields, 0, $field_count;
#sum them
my $sum = 0;
$sum += $_ for @group;
my $avg = $sum / @group; #divide by number of elements in this group, so it'll work if there's 1 or 2 'trailing'.
#stash that in the new field list.
push @new_fields, $avg;
}
#print the output line.
print join "\t", $samplename, @new_fields,"\n"
}