my @actual_mat = ( [ 0.994704478, 0.000882587, 0.000882587, 0.000882587, 0.002647761], [ 0.005270463, 0.989459074, 0.002635231, 0.002635231, 0.000000000], [ 0.000000000, 0.000000000, 0.005282977, 0.000000000, 0.000000000]. [ 0.000000000, 0.000000000, 0.000000000, 1.000000000, 0.000000000], [ 0.000000000, 0.000000000, 0.000000000, 0.000000000, 1.000000000] ); # It is simply done by assigning the value in @real_value given # the corresponding (@row,@index) as coordinate; # e.g. to assign $real_value[-1] into # $actual_mat[$row_index[-1]-1,$col_index[-1]-1);