in reply to Re^2: How to ignore ampersand and pound signs?
in thread How to ignore ampersand and pound signs?
my $s = q[<IL.Check/>]; my $r = q[<√>]; print "Old word: $s\n"; $s =~ s/$s/$r/; print "New word: $s\n";
There's no interpolation or escape sequences here. q vs qq is moot.
The real problem is that you are using text as a regex pattern without first converting it to a regex pattern. ("#" is special under "x".) Use quotemeta or its alias \Q..\E:
my $s = q[<IL.Check/>]; my $r = q[<√>]; print "Old word: $s\n"; $s =~ s/\Q$s\E/$r/; print "New word: $s\n";
|
|---|