At 16:25 -0500 2001.11.13, Greg London wrote:
>Is there a binary equivalent to the "hex" function?
>
>I have a string that represents a binary value,
>and I want to convert it to an integer value
>and do some math with it.
>
>if it were a hex string, I'd "hex" it.
>what if its a binary string?

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

        01100001011000100110001101100100
        abcd

Or "b" instead of "B" (see pack docs).

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

Reply via email to