use Data::Dumper; my $header = ; my @cols_h = split /\t/, $header; my @data; while () { chomp; my @info = split /\t/; push @data, \@info; } # uncomment this to see the data we have so far. #print Dumper(\@data); foreach (@data) { my $avg = ($_->[2] + $_->[3]) / 2; push @$_, $avg } # uncomment this to see the data we have so far. #print Dumper(\@data); # at this point, each @data is an array of arrays. # Each of the arrays contained in @data is "anonymous" (unnamed). # These anonymous arrays have the four columns (0-3), and a fifth column # which is an average of columns 2 and 3 (zero-based). __DATA__ ID_REF IDENTIFIER GSM29783 GSM29784 31307_at L17325 77 788 31308_at L17330 -777 -877 31309_r_at U50277 7 8 31310_at X52009 -7777 -887 31311_at X61070 77777 88