in reply to Re: string substitution
in thread string substitution

> FWIW: Perl can apply mask operations with & , ^ and | , but this would also first require translating X to chr(255) and else to chr(0). see tr and s for that approach.

(used uppercase X for demo only, switching to lowercase works too)

use v5.12; use warnings; # https://perlmonks.org/?node_id=11141581 my $in = "anXwxdXdzd"; my $pi = "1415926535"; my $mask = $in =~ tr/Xa-z/\xff\x00/r; my $re = $pi & $mask; $re=~ tr/\x00/./; $re = "/bin/grep $re /path/to/some/file"; say $re;
OUTPUT:
/bin/grep ..1...6... /path/to/some/file

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery