Hi, ok here it is (pardon me..its pretty long):
#!/usr/bin/perl --
## by us
## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if " -otr -opr
+-ce -nibc -i=4 -pt=0 "-nsak=*"
#!/usr/bin/perl --
use strict; use warnings;
use Data::Dump qw/ dd /;
Main( @ARGV );
exit( 0 );
sub Main {
UsedToBeJustDoWork();
}
sub UsedToBeJustDoWork {
my $full_data = [
["M11", 446, 0.450, 287.41, 217.76, 231.21, 746.84, 661.86, 812.
+52],
["M12", 224, 0.455, 503.91, 579.54, 418.29, 1613.59, 1689.682, 1
+542.565],
["M13", 225, 0.455, 288.69, 358.43, 231.10, 817.81, 996.18, 763.
+18],
];
my $d_h = [
[287.41, 217.76, 231.21, 746.84, 661.86, 812.52],
[503.91, 579.54, 418.29, 1613.59, 1689.682, 1542.565],
[288.69, 358.43, 231.10, 817.81, 996.18, 763.18],
];
## I don't know what you want here
## ratio calculation
# first group
my $ratio1_1_1 = $$d_h[0][0] / $$d_h[0][0];
my $ratio1_2_1 = $$d_h[1][0] / $$d_h[0][0];
my $ratio1_3_1 = $$d_h[2][0] / $$d_h[0][0];
my $ratio1_1_2 = $$d_h[0][0] / $$d_h[1][0];
my $ratio1_2_2 = $$d_h[1][0] / $$d_h[1][0];
my $ratio1_3_2 = $$d_h[2][0] / $$d_h[1][0];
my $ratio1_1_3 = $$d_h[0][0] / $$d_h[2][0];
my $ratio1_2_3 = $$d_h[1][0] / $$d_h[2][0];
my $ratio1_3_3 = $$d_h[2][0] / $$d_h[2][0];
my $ratio2_1_1 = $$d_h[0][1] / $$d_h[0][1];
my $ratio2_2_1 = $$d_h[1][1] / $$d_h[0][1];
my $ratio2_3_1 = $$d_h[2][1] / $$d_h[0][1];
my $ratio2_1_2 = $$d_h[0][1] / $$d_h[1][1];
my $ratio2_2_2 = $$d_h[1][1] / $$d_h[1][1];
my $ratio2_3_2 = $$d_h[2][1] / $$d_h[1][1];
my $ratio2_1_3 = $$d_h[0][1] / $$d_h[2][1];
my $ratio2_2_3 = $$d_h[1][1] / $$d_h[2][1];
my $ratio2_3_3 = $$d_h[2][1] / $$d_h[2][1];
my $ratio3_1_1 = $$d_h[0][2] / $$d_h[0][2];
my $ratio3_2_1 = $$d_h[1][2] / $$d_h[0][2];
my $ratio3_3_1 = $$d_h[2][2] / $$d_h[0][2];
my $ratio3_1_2 = $$d_h[0][2] / $$d_h[1][2];
my $ratio3_2_2 = $$d_h[1][2] / $$d_h[1][2];
my $ratio3_3_2 = $$d_h[2][2] / $$d_h[1][2];
my $ratio3_1_3 = $$d_h[0][2] / $$d_h[2][2];
my $ratio3_2_3 = $$d_h[1][2] / $$d_h[2][2];
my $ratio3_3_3 = $$d_h[2][2] / $$d_h[2][2];
#second group
my $ratio4_1_1 = $$d_h[0][3] / $$d_h[0][3];
my $ratio4_2_1 = $$d_h[1][3] / $$d_h[0][3];
my $ratio4_3_1 = $$d_h[2][3] / $$d_h[0][3];
my $ratio4_1_2 = $$d_h[0][3] / $$d_h[1][3];
my $ratio4_2_2 = $$d_h[1][3] / $$d_h[1][3];
my $ratio4_3_2 = $$d_h[2][3] / $$d_h[1][3];
my $ratio4_1_3 = $$d_h[0][3] / $$d_h[2][3];
my $ratio4_2_3 = $$d_h[1][3] / $$d_h[2][3];
my $ratio4_3_3 = $$d_h[2][3] / $$d_h[2][3];
my $ratio5_1_1 = $$d_h[0][4] / $$d_h[0][4];
my $ratio5_2_1 = $$d_h[1][4] / $$d_h[0][4];
my $ratio5_3_1 = $$d_h[2][4] / $$d_h[0][4];
my $ratio5_1_2 = $$d_h[0][4] / $$d_h[1][4];
my $ratio5_2_2 = $$d_h[1][4] / $$d_h[1][4];
my $ratio5_3_2 = $$d_h[2][4] / $$d_h[1][4];
my $ratio5_1_3 = $$d_h[0][4] / $$d_h[2][4];
my $ratio5_2_3 = $$d_h[1][4] / $$d_h[2][4];
my $ratio5_3_3 = $$d_h[2][4] / $$d_h[2][4];
my $ratio6_1_1 = $$d_h[0][5] / $$d_h[0][5];
my $ratio6_2_1 = $$d_h[1][5] / $$d_h[0][5];
my $ratio6_3_1 = $$d_h[2][5] / $$d_h[0][5];
my $ratio6_1_2 = $$d_h[0][5] / $$d_h[1][5];
my $ratio6_2_2 = $$d_h[1][5] / $$d_h[1][5];
my $ratio6_3_2 = $$d_h[2][5] / $$d_h[1][5];
my $ratio6_1_3 = $$d_h[0][5] / $$d_h[2][5];
my $ratio6_2_3 = $$d_h[1][5] / $$d_h[2][5];
my $ratio6_3_3 = $$d_h[2][5] / $$d_h[2][5];
## name the vars what you want
## make the program runnable ... like this
my $these_firstgroup_row1_avg = ($ratio1_1_1 + $ratio2_1_1 + $rat
+io3_1_1) / 3;
my $these_firstgroup_row2_avg = ($ratio1_2_1 + $ratio2_2_1 + $rati
+o3_2_1) / 3;
my $these_firstgroup_row3_avg = ($ratio1_3_1 + $ratio2_3_1 + $rat
+io3_3_1)/ 3;
my $these_firstgroup_row4_avg = ($ratio1_1_2 + $ratio2_1_2 + $rat
+io3_1_2) / 3;
my $these_firstgroup_row5_avg = ($ratio1_2_2 + $ratio2_2_2 + $rati
+o1_2_2) / 3;
my $these_firstgroup_row6_avg = ($ratio1_3_2 + $ratio2_3_2 + $rat
+io3_3_2)/ 3;
my $these_firstgroup_row7_avg = ($ratio1_1_3 + $ratio2_1_3 + $rat
+io3_1_3) / 3;
my $these_firstgroup_row8_avg = ($ratio1_2_3 + $ratio2_2_3 + $rati
+o3_2_3) / 3;
my $these_firstgroup_row9_avg = ($ratio1_3_3 + $ratio2_3_3 + $rat
+io3_3_3)/ 3;
my $these_secondgroup_row1_avg = ($ratio4_1_1 + $ratio5_1_1 + $ra
+tio6_1_1) / 3;
my $these_secondgroup_row2_avg = ($ratio4_2_1 + $ratio5_2_1 + $rat
+io6_2_1) / 3;
my $these_secondgroup_row3_avg = ($ratio4_3_1 + $ratio5_3_1 + $ra
+tio6_3_1)/ 3;
my $these_secondgroup_row4_avg = ($ratio4_1_2 + $ratio5_1_2 + $ra
+tio6_1_2) / 3;
my $these_secondgroup_row5_avg = ($ratio4_2_2 + $ratio5_2_2 + $rat
+io6_2_2) / 3;
my $these_secondgroup_row6_avg = ($ratio4_3_2 + $ratio5_3_2 + $ra
+tio6_3_2)/ 3;
my $these_secondgroup_row7_avg = ($ratio4_1_3 + $ratio5_1_3 + $ra
+tio6_1_3) / 3;
my $these_secondgroup_row8_avg = ($ratio4_2_3 + $ratio5_2_3 + $rat
+io6_2_3) / 3;
my $these_secondgroup_row9_avg = ($ratio4_3_3 + $ratio5_3_3 + $ra
+tio6_3_3)/ 3;
## you want these?? not needed
# my $these_column_d_avg = $$d_h[0][0] + $$d_h[1][0] + $$d_h[2][0]
+/ 3;
# my $these_column_e_avg = $$d_h[0][1] + $$d_h[1][1] + $$d_h[2][1]
+/ 3;
# my $these_column_f_avg = $$d_h[0][2] + $$d_h[1][2] + $$d_h[2][2]
+/ 3;
# my $these_column_g_avg = $$d_h[0][3] + $$d_h[1][3] + $$d_h[2][3]
+/ 3;
# my $these_column_h_avg = $$d_h[0][4] + $$d_h[1][4] + $$d_h[2][4]
+/ 3;
## these are for your final data structure
## what do you want to have here
my $these_firstgroup_row1 = [ $these_firstgroup_row1_avg ];
my $these_firstgroup_row2 = [ $these_firstgroup_row2_avg ];
my $these_firstgroup_row3 = [ $these_firstgroup_row3_avg ];
my $these_firstgroup_row4 = [ $these_firstgroup_row4_avg ];
my $these_firstgroup_row5 = [ $these_firstgroup_row5_avg ];
my $these_firstgroup_row6 = [ $these_firstgroup_row6_avg ];
my $these_firstgroup_row7 = [ $these_firstgroup_row7_avg ];
my $these_firstgroup_row8 = [ $these_firstgroup_row8_avg ];
my $these_firstgroup_row9 = [ $these_firstgroup_row9_avg ];
my $these_secondgroup_row1 = [ $these_secondgroup_row1_avg ];
my $these_secondgroup_row2 = [ $these_secondgroup_row2_avg ];
my $these_secondgroup_row3 = [ $these_secondgroup_row3_avg ];
my $these_secondgroup_row4 = [ $these_secondgroup_row4_avg ];
my $these_secondgroup_row5 = [ $these_secondgroup_row5_avg ];
my $these_secondgroup_row6 = [ $these_secondgroup_row6_avg ];
my $these_secondgroup_row7 = [ $these_secondgroup_row7_avg ];
my $these_secondgroup_row8 = [ $these_secondgroup_row8_avg ];
my $these_secondgroup_row9 = [ $these_secondgroup_row9_avg ];
my $final_output_wanted = [
$these_firstgroup_row1,
$these_secondgroup_row1,
$these_firstgroup_row2,
$these_secondgroup_row2,
$these_firstgroup_row3,
$these_secondgroup_row3,
$these_firstgroup_row4,
$these_secondgroup_row4,
$these_firstgroup_row5,
$these_secondgroup_row5,
$these_firstgroup_row6,
$these_secondgroup_row6,
$these_firstgroup_row7,
$these_secondgroup_row7,
$these_firstgroup_row8,
$these_secondgroup_row8,
$these_firstgroup_row9,
$these_secondgroup_row9,
];
dd ( $final_output_wanted );
} ## end sub UsedToBeJustDoWork
_Output Data_
[
[1],
[1],
["2.07"],
["2.20"],
["1.21"],
["1.17"],
["0.49"],
["0.46"],
[1],
[1],
["0.58"],
["0.53"],
["0.86"],
["0.88"],
["1.72"],
["1.89"],
[1],
[1],
]
Am able to run the code and get the output correctly. So what's the next step I should take?
|