my $string="01100110 01100101 01100101 01101100 01101001 01101110 01100111 00100000 01101100"; #$string=~ s/ (\d+)/pack('B8', $1)/egx; # way 1 $string=~ s/ (\d+)/chr(oct('0b'.$1))/egx; # way 2 #### chr('0b'.$1) #it will throw a error message: Argument "0b01100110 " isn't numeric #### +('0b'~'0111011') #perl6