but will it convert '0b1ken0b' ? Sorry-couldn't-resist Steve
> -----Original Message----- > From: Ronald J Kimball [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, November 13, 2001 4:31 PM > To: Greg London > Cc: mongers of perl > Subject: Re: [Boston.pm] binary, hexadecimal, decimal, oh my > > > On Tue, Nov 13, 2001 at 04:25:26PM -0500, 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? > > In perl5.6.0 or later, you can use oct() to convert a binary > string that > starts with 0b, e.g. oct('0b11') == 3. > > Ronald >
