while (){ chomp; push @rdata, $_; } while (){ chomp; push @rdata, $_; } my @sum = map {$rdata[$_] + $pdata[$_]} 0..$_#a;