#!/usr/bin/perl use warnings; use strict; my $buf; my @barray; my $byt; my $acc = 0; # file 'datafile.bin' must exist and be in same directory as program file. open BFILE, "<./datafile.bin" or die "Can't find or open binary data file.\n"; # not necessary on UNIX but helps with line-delineated files on Doze. binmode BFILE; # program will create 'tfile.csv' in same directory open OFILE, ">./tfile.csv" or die "Can't create output file.\n"; while ( read BFILE, $buf, 64 ) { my $bindex = 0; @barray = unpack('C*', $buf); for ( my $batch = 0; $batch < 16; $batch++ ) { $acc = 0; for ( my $i = 0; $i < 4; $i++ ) { if ( exists( $barray[ $bindex ] ) ) { $byt = $barray[ $bindex++ ]; $acc *= 256; $acc += $byt; } } printf OFILE '"' . $acc . "\","; } printf OFILE "\n"; } close BFILE; close OFILE;