Wiggins has asked for the wisdom of the Perl Monks concerning the following question:
Given, I have 'slurped' this (hex dumped) data into a scalar:
I wish to repeatedly extract 4 bytes, and interpret them as a signed (little-endian) integer; stopping when I find a value of -1.00000000 d0 cf 11 e0 a1 b1 1a e1 00 00 00 00 00 00 00 00 |......... +.......| 00000010 00 00 00 00 00 00 00 00 3e 00 03 00 fe ff 09 00 |........> +.......| 00000020 06 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 |......... +.......| 00000030 38 00 00 00 00 00 00 00 00 10 00 00 3a 00 00 00 |8........ +...:...| 00000040 01 00 00 00 fe ff ff ff 00 00 00 00 37 00 00 00 |......... +...7...| 00000050 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |......... +.......|
I have attempted using a 'substr' in a loop indexed +4 for extraction; then packing the restult as an 'i'. But I don't seem to find an operation that results in 3759263696 for the first 4 bytes.
--UPDATE I got some results; not what I had expected, but not necessarily wrong, with:
Upon reflection, this is probably correct, and just what I needed.@r = unpack "i30" , $doc; print join (",",@r); ---- -535703600,-518344287,0,0,0,0,196670,655358,6,0,0,1,56,0,4096,58,1,-2, +0,55,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: To 'pack' or 'unpack' that is the question
by almut (Canon) on Nov 11, 2008 at 15:32 UTC | |
|
Re: To 'pack' or 'unpack' that is the question
by gone2015 (Deacon) on Nov 11, 2008 at 16:25 UTC | |
|
Re: To 'pack' or 'unpack' that is the question
by Anonymous Monk on Nov 11, 2008 at 15:30 UTC |