sub data { for $arr_ref1 (@full_data) { for $arr_ref2(@full_data) { for $index (3..$#$arr_ref2) { $ratio = sprintf( "%.2f%s", $$arr_ref2[$index]/$$arr_ref1[$index],"\t"); print OUT1 "$ratio"; } print OUT1 "\n"; #print D to E columns into next line after one loop } } } _DATA_ (A to G is just to indicate column location) A B C D E F G AX8 0.23 42.4 1 1 1 1 AX4 0.65 53.6 0.2 7.8 9.1 2.3 AX12 0.34 23.9 3.2 7.2 1.2 9.3 #### for $index (3..$#$arr_ref2) { $ratio = sprintf( "%.2f%s", $$arr_ref2[$index]/$$arr_ref1[$index],"\t"); #print OUT1 "$ratio"; } print OUT1 "\n"; #print D to E columns into next line after one loop push (@data1, $ratio1); print OUT1 ($data1); } #### D and E (by rows) --> 1st array F and G (by rows) --> 2nd array