in reply to correct usage of q, quotemeta, with s///
As noted above, you can use either the \Q...\E construct or quotemeta() - it works something like this:
The \Q .. \E construct is a little easier in this case, because you can embed it in your match - you should not use it in the replacement part of a substitution, because that's (a lot like) a regular double-quoted string:my $string = 'abc!hu('; print "\Q$string\E\n"; # prints abc\!hu\( print quotemeta $string; # prints abc\!hu\(
s/\Q$string\E/$replacement/; # or .. $qstring = quotemeta $string; s/$qstring/$replacement/;
For (a lot more) info, take a look at
</code>perldoc perlre perldoc perlop (the m// part)
-- Joost downtime n. The period during which a system is error-free and immune from user input.
|
|---|