in reply to Re^2: How to substitute a string containing "\" with same string in quotes.
in thread How to substitute a string containing "\" with same string in quotes.

No, $string and $substring don't contains any "\" to begin with.
# The string these literals produce don't contains any "\". my $string = "my string with \ and / slashes."; my $substring = "with \ and / slashes"; print("$string\n"); print("$substring\n"); print("\n"); # This is what the literals should be. $string = "my string with \\ and / slashes."; $substring = "with \\ and / slashes"; print("$string\n"); print("$substring\n"); print("\n"); # It works. $string =~ s/\Q$substring\E/\"$substring\"/gi; print("$string\n");
my string with and / slashes. with and / slashes my string with \ and / slashes. with \ and / slashes my string "with \ and / slashes".