I have N number of floats in each line of the input text file. I'm trying to convert them into binary format (sequence of four-byte floats).
Sample line from input: -12.391 -5.301 -12.854 0.438 8.499 4.862 -2.481 3.962
I'm using the Perl pack
function as below
foreach my $line (@inputData) {
print $outFileHandle pack('fxfxfxfx... N times', $line);
}
Instead of writing fx
N times, what can I do?