in reply to Re: unpack in incrementing variables
in thread unpack in incrementing variables

Thank you. At last the answer to the question I actually asked. The question was why, not how. The answer is "Unpack operates on strings not on integers".


Perl is Huffman encoded by design.

Replies are listed 'Best First'.
Re^3: unpack in incrementing variables
by demerphq (Chancellor) on Oct 14, 2005 at 09:44 UTC

    I think people were inclined to show the how because the why is in the docs:

    unpack TEMPLATE,EXPR
    "unpack" does the reverse of "pack": it takes a string and expands it out into a list of values. (In scalar context, it returns merely the first value produced.)

    But I did it because i hadnt had my coffee before I posted (was waiting for it finish being made) and didnt read the question properly. Luckily the coffee was finished just after I hit submit so I realized the error and fixed it right after. :-)

    ---
    $world=~s/war/peace/g

      Funny how one can read the docs and see what one wants to see. I read that a day ago when I was trying to figure the problem out and thought "I yes, a number is stored as a string of bytes so that should be fine". Argh.


      Perl is Huffman encoded by design.
Re^3: unpack in incrementing variables
by Roy Johnson (Monsignor) on Oct 14, 2005 at 17:59 UTC
    The question was why, not how.
    The question "Is it possible to...?" includes an implicit "How?" Answering such question with a simple "yes" is generally seen as teasing.

    Caution: Contents may have been coded under pressure.