locinus has asked for the wisdom of the Perl Monks concerning the following question:
Hi monks.
I'm new using unpack function to get data from an external binary source. I'm having trouble getting the right values.
My first value is coded as an unsigned 16-bit integer, little-endian. When I open it with my hex editor, I can see that the two first bytes are coded "DC 20", which represents 8412, which is the value I expect.
My perl code is the following:
my $fh = FileHandle->new; open ($fh, '<', $filename) or die 'missing file'; binmode $fh, ':raw'; my @values = unpack 'S<', $fh; print @values;
and provides the value 26950. I really can't figure out where this data comes from. Same if I provide '<:raw' to the open function.
I'm running on Windows 7 64-bit, Perl 5.12.3.
Any idea/suggestion? I'm clueless right now.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using unpack on Windows with external data
by dave_the_m (Monsignor) on Aug 27, 2016 at 12:02 UTC | |
by locinus (Initiate) on Mar 04, 2017 at 21:27 UTC | |
|
Re: Using unpack on Windows with external data
by johngg (Canon) on Aug 27, 2016 at 21:30 UTC |