MSoegtrop has asked for the wisdom of the Perl Monks concerning the following question:
really does a plain string replace, because the replace part has meta symbols as well (e.g. \1) and these are not quoted. And what happens if $find happens to contain \E? Is using quotemeta safer than using \Q and \E? And is there something like quotemeta for the replace part?s/\Q$find\E/$replace/g
Or is there a simple function that does a simple string replace? Sure i can easily write one, but i am sure there is a simple way of doing this, that doesn't give me bad dreams of failing perl scripts in the night, and is still elegant.
Michael
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Does s/\Q$find\E/$replace/g really a plain string replace ?
by ikegami (Patriarch) on Oct 02, 2004 at 16:05 UTC | |
by diotalevi (Canon) on Oct 02, 2004 at 16:23 UTC | |
by ikegami (Patriarch) on Oct 02, 2004 at 16:32 UTC | |
by !1 (Hermit) on Oct 02, 2004 at 21:57 UTC | |
|
Re: Does s/\Q$find\E/$replace/g really a plain string replace ?
by !1 (Hermit) on Oct 02, 2004 at 21:51 UTC |