I humbly submit this question, but these two hold great confusion for me. Especially when mixed with fileIO and implicit conversions.

Given, I have 'slurped' this (hex dumped) data into a scalar:

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 wish to repeatedly extract 4 bytes, and interpret them as a signed (little-endian) integer; stopping when I find a value of -1.

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:

@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
Upon reflection, this is probably correct, and just what I needed.

In reply to To 'pack' or 'unpack' that is the question by Wiggins

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.