my $test = 'illegal\\\\characters*example?';
my @illegal = qw(\ * ?);
my @legal = qw(bs a q);
my $c = 0;
foreach my $val (@illegal) {
$test =~ s/\Q$val\E/[$legal[$c]]/g;
$c++;
}
print $test."\n";
####
A single-quoted, literal string. A backslash
represents a backslash unless followed by the
delimiter or another backslash, in which case the
delimiter or backslash is interpolated.
####
my $test = 'illegal\\\\characters*example?';
my @illegal = qw(\ * ?);
my @legal = qw(bs a q);
my $c = 0;
foreach my $val (@illegal) {
$test =~ s/\Q$val\E/[$legal[$c]]/g;
$c++;
}
print $test."\n";