Re: hex represenation from string in perl



Jim Gibson wrote:
> <faq>
>
> How do I convert from binary to decimal
> Perl 5.6 lets you write binary numbers directly with the 0b nota-
> tion:
>
> number = 0b10110110;
>
> Using oct:
>
> my $input = "10110110";
> $decimal = oct( "0b$input" );
>
> Using pack and ord:
>
> $decimal = ord(pack('B8', '10110110'));
>
> </faq>

Er. Out of curiousity, what version of Perl is this? That FAQ is not
on my system (This is perl, v5.6.1 built for sun4-solaris), nor is it
at http://perldoc.perl.org/perlfaq.html

Paul Lalli

.



Relevant Pages

  • Re: removing a line from a file
    ... Paul Lalli wrote: ... It is hard to convert from ksh to perl. ... Prev by Date: ...
    (comp.lang.perl.misc)
  • Re: warning: non-DWIM behavior
    ... Paul Lalli wrote: ... > Larry wrote: ... maybe it once did in a long-ago version of Perl? ... Prev by Date: ...
    (comp.lang.perl.misc)
  • Re: from a file to an array of words
    ... > There is no function named "getlines" in Perl. ... Paul Lalli ... Prev by Date: ...
    (comp.lang.perl.misc)
  • Re: hex represenation from string in perl
    ... > Jim Gibson wrote: ... Out of curiousity, what version of Perl is this? ... Prev by Date: ...
    (comp.lang.perl.misc)
  • Re: Cant get group to match - please help
    ... >> Paul Lalli wrote: ... >>> It requires neither greatness nor wisdom to read the posting guidelines ... > Meaning that you found this newsgroup, and decided to dig right in and ... Actually I did do a search in the three perl reference books I have ...
    (comp.lang.perl.misc)