Are you really, really sure that you get eight bytes from your file, the first having the value 0x0D and the second having the value 0x0E (and so on)?
If so, you might need to do some bit twiddling to combine all the nibbles:
use Data::Dumper;
my $str = "\x0D\x0E\x0A\x0D\x0B\x0E\x0E\x0F";
my @bytes = unpack 'C8', $str;
print Dumper \@bytes;
# Now add up the byte-pairs
for (0..3) {
$bytes[ $_ ] = $bytes[ $_*2 ] * 16 + $bytes[ $_*2 +1 ];
};
splice @bytes, 4; # we only need the first four entries
print Dumper \@bytes;
my $num = unpack 'N', pack 'C4', @bytes;
print sprintf "%08x (%i)", $num, $num;
But if you get a string of four bytes, one of the two pack templates "N" or "V" will help you. See the following:
my $str = "\xDE\xAD\xBE\xEF";
my $num = unpack 'N', $str;
print sprintf "%08x (%i)", $num, $num;
But I already told you this and you didn't show any code. |