Hi
Check the input itself is not containing the '\', because it is interpolated in double quotes.
use strict; my $string = "this is my sting with \ and /slashes. put substing in qu +otes"; my $substring = "with \ and /slashes"; print $string; $string =~ s/\Q$substring\E/\"$substring\"/gi; OUTPUT: this is my sting with and /slashes. put substing in quotes
Instead use single quote in the input like,
use strict; my $string = 'this is my sting with \ and /slashes. put substing in qu +otes'; my $substring = 'with \ and /slashes'; print $string; $string =~ s/\Q$substring\E/\"$substring\"/gi; OUTPUT: this is my sting with \ and /slashes. put substing in quotes
This will give the correct output
Punitha
In reply to Re^3: How to substitute a string containing "\" with same string in quotes.
by Punitha
in thread How to substitute a string containing "\" with same string in quotes.
by Rapunzel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |