in reply to adding array elements
Though this does not check whether the amount of fields is actually the same or not :)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);
|
|---|