At 16:31 -0500 2001.11.13, Ronald J Kimball wrote:
>In perl5.6.0 or later, you can use oct() to convert a binary string that
>starts with 0b, e.g. oct('0b11') == 3.

Ah, I didn't know that.  Weird.

FWIW, to get the integer from the code I posted, just unpack with "l":

        #!perl -wl
        print $bits = unpack("B*", 'abcd');
        print unpack("l", pack("B*", $bits));
        print oct("0b$bits");

        01100001011000100110001101100100
        1633837924
        1633837924

-- 
Chris Nandor                      [EMAIL PROTECTED]    http://pudge.net/
Open Source Development Network    [EMAIL PROTECTED]     http://osdn.com/

Reply via email to