in reply to adding array elements

You could do this by maintaining an array in which you keep incrementing the various fields as you read lines. Like so:
use strict; my @data; open(INPUT,'<',"monks.dat") or die("Can't open file"); while (<INPUT>) { chomp; my @newdata = split(/ +/); for my $index (0 .. $#newdata) { $data[$index] += $newdata[$index]; } } close(INPUT);
Though this does not check whether the amount of fields is actually the same or not :)