Hello I have a matrix which contains floats and int numbers I want to print it to a file in a way if it's not integer print the value rounded to 1 number after float. Below is my code
use Scalar::Util::Numeric qw(isint);
for ( $i = 0 ; $i < $#matrix ; $i++ ) {
for ( $j = 0 ; $j < $#{ $matrix[0] } ; $j++ ) {
if (not isint $matrix[$i][$j] ) {
printf MYFILE ("%.1f",$matrix[$i][$j]{score});
}
else {
print MYFILE $matrix[$i][$j]{score}.' ';
}
}
print MYFILE "\n";
}
The problem is that this code output write everything as float even if it is an integer. How to fix it ?