Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: Reading binary file in perl having records of different length

by Anonymous Monk
on Jun 17, 2014 at 16:13 UTC ( #1090166=note: print w/replies, xml ) Need Help??


in reply to Re^2: Reading binary file in perl having records of different length
in thread Reading binary file in perl having records of different length

See pack patterns "n" and "v" instead, or the "<" and ">" modifiers if you really want signed interpretation.

$ perl -le 'print unpack("v","\x03\x50")' 20483 $ perl -le 'print unpack("n","\x03\x50")' 848 $ perl -le 'print unpack("s<","\x03\x50")' 20483 $ perl -le 'print unpack("s>","\x03\x50")' 848
  • Comment on Re^3: Reading binary file in perl having records of different length
  • Download Code

Replies are listed 'Best First'.
Re^4: Reading binary file in perl having records of different length
by jaypal (Beadle) on Jun 17, 2014 at 16:33 UTC

    Awesome!! The use of "n" pattern worked great.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1090166]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (1)
As of 2016-09-25 19:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (472 votes). Check out past polls.