xiaoyafeng has asked for the wisdom of the Perl Monks concerning the following question:
Hi monks,
I received a binary string on twitter, and I translated it into words in perl:
My question is why perl do not supportmy $string="01100110 01100101 01100101 01101100 01101001 01101110 0110 +0111 00100000 01101100"; #$string=~ s/ (\d+)/pack('B8', $1)/egx; # way 1 $string=~ s/ (\d+)/chr(oct('0b'.$1))/egx; # way 2
Thanks very much!chr('0b'.$1) #it will throw a error message: Argument "0b01100110 " is +n't numeric
UPDATE:
I mean, I know I should pass a number to chr, but is there a way to convert a string to number explicitly like perl6?+('0b'~'0111011') #perl6
I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: what is difference between chr and oct?
by bluescreen (Friar) on Jul 12, 2010 at 17:52 UTC | |
|
Re: what is difference between chr and oct?
by JavaFan (Canon) on Jul 12, 2010 at 17:28 UTC | |
by xiaoyafeng (Deacon) on Jul 12, 2010 at 17:36 UTC | |
by afoken (Chancellor) on Jul 13, 2010 at 02:24 UTC | |
by xiaoyafeng (Deacon) on Jul 13, 2010 at 15:04 UTC | |
by JavaFan (Canon) on Jul 13, 2010 at 15:29 UTC | |
|
Re: what is difference between chr and oct?
by Khen1950fx (Canon) on Jul 12, 2010 at 18:34 UTC | |
|
Re: what is difference between chr and oct?
by toolic (Bishop) on Jul 12, 2010 at 17:20 UTC | |
by xiaoyafeng (Deacon) on Jul 12, 2010 at 17:32 UTC |