in reply to using tr
Like this?:
$s = pack 'C*', 33 .. 126;; print $s;; !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdef +ghijklmnopqrstuvwxyz{|}~ $x = join'', '0'x10, '1'x10, '2'x10, '3'x64;; eval qq[\$s =~ tr[\\x20-\\x7e][$x]];; print $s;; 0000000001111111111222222222233333333333333333333333333333333333333333 +333333333333333333333333
Or, without the eval (Updated: The last character in the replacement is reused so shortening the construct):
$s = pack 'C*', 33 .. 126;; print $s;; !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdef +ghijklmnopqrstuvwxyz{|}~ $s =~ tr[\x20-\x7e][0000000000111111111122222222223];; print $s;; 0000000001111111111222222222233333333333333333333333333333333333333333 +333333333333333333333333
ps. Please find out what <code></code> tags are and use them in future.
|
|---|