Rapunzel has asked for the wisdom of the Perl Monks concerning the following question:
I dont want to use line 3 and 5 of my code.1 my $sting = "this is my sting with \ and /slashes. put substing in q +uotes"; 2 my $substring = "with \ and /slashes"; 3 $substing =~ s/\\/\\\\/g; 4 $string =~ s/$substring/\"$substring\"/gi; 5 $string =~ s/\\\\/\\/g;
Please let me know better way to do this.
Thanks,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to substitute a string containing "\" with same string in quotes.
by ikegami (Patriarch) on Oct 24, 2008 at 08:47 UTC | |
by Anonymous Monk on Oct 24, 2008 at 09:53 UTC | |
|
Re: How to substitute a string containing "\" with same string in quotes.
by Punitha (Priest) on Oct 24, 2008 at 08:48 UTC | |
by Rapunzel (Novice) on Oct 24, 2008 at 08:54 UTC | |
by ikegami (Patriarch) on Oct 24, 2008 at 09:08 UTC | |
by Punitha (Priest) on Oct 24, 2008 at 09:06 UTC |