in reply to What do \Q and \E mean?
What's between \Q and \E is treated as normal characters, not regexp characters. For example,
'.' =~ /./; # match 'a' =~ /./; # match '.' =~ /\Q.\E/; # match 'a' =~ /\Q.\E/; # no match
It doesn't stop variables from being interpolated.
$search = '.'; '.' =~ /$search/; # match 'a' =~ /$search/; # match '.' =~ /\Q$search\E/; # match 'a' =~ /\Q$search\E/; # no match
By the way, I think you want
"s{\\Q\$in\\E}{\$out}g"
instead of
"s{\\Q$in\\E}{$out}g"
The difference will be seen when $in or $out contains a '$'.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: What do \Q and \E mean?
by apt_get (Acolyte) on Jun 19, 2005 at 03:17 UTC | |
|
Re^2: What do \Q and \E mean?
by apt_get (Acolyte) on Jun 19, 2005 at 02:57 UTC | |
by ikegami (Patriarch) on Jun 19, 2005 at 03:03 UTC | |
by cbrandtbuffalo (Deacon) on Jun 19, 2005 at 15:21 UTC |