hellohello1 has asked for the wisdom of the Perl Monks concerning the following question:
Hello!
I have a question. I have a code:
(OUT1 refers to textfile)
My problem here is the (print OUT1 "$ratio";) line onwards. Instead of printing the output into textfile, is it possible to print the output into an array or something so that I can carry on with the calculation of the output from there? I have tried something like this (push data into array) :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[$ind +ex],"\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
But am not getting the desired output. I just can't figure out how to get those output and store into variables/arrays instead of printing it out. My desired outcome is to put:for $index (3..$#$arr_ref2) { $ratio = sprintf( "%.2f%s", $$arr_ref2[$index]/$$arr_ref1[$ind +ex],"\t"); #print OUT1 "$ratio"; } print OUT1 "\n"; #print D to E columns into next line +after one loop push (@data1, $ratio1); print OUT1 ($data1); }
so that I can calculate their average and standard deviation for both arrays and put into the next column beside G. Or is there other way to do it?D and E (by rows) --> 1st array F and G (by rows) --> 2nd array
|
---|
Back to
Seekers of Perl Wisdom