in reply to unpack in incrementing variables

print unpack ('B16', pack('I', $_))."\n" for (0..10);

Replies are listed 'Best First'.
Re^2: unpack in incrementing variables
by GrandFather (Saint) on Oct 14, 2005 at 02:14 UTC

    Close, but no banana.

    print unpack ('B16', pack('I', $_))."\n" for (250..260); 1111101000000000 1111101100000000 1111110000000000 1111110100000000 1111111000000000 1111111100000000 0000000000000001 0000000100000001 0000001000000001 0000001100000001 0000010000000001

    which is not what I would like either.

    Besides, the question was why, not how. I have a how.


    Perl is Huffman encoded by design.

      Counter intuitively (for me at least):

      print unpack ('B16', pack('n', $_))."\n" for (250..260); 0000000011111010 0000000011111011 0000000011111100 0000000011111101 0000000011111110 0000000011111111 0000000100000000 0000000100000001 0000000100000010 0000000100000011 0000000100000100

      the "network" format (big endian) does what I want on a little endian (Windows) system.


      Perl is Huffman encoded by design.
        Thanks. I was going to check that, but I was called away. I figured a partial post would guide someone on the right path.