Returns the value of EXPR with all non-"word"
characters backslashed. (That is, all characters not matching
/[A-Za-z_0-9]/
will be preceded by a backslash in the
returned string, regardless of any locale settings.)
This is the internal function implementing
the \Q
escape in double-quoted strings.
If EXPR is omitted, uses $_
.
quotemeta (and \Q
... \E
) are useful when interpolating strings into
regular expressions, because by default an interpolated variable will be
considered a mini-regular expression. For example:
Will cause $sentence
to become 'The big bad wolf jumped over...'
.
On the other hand:
Or:
Will both leave the sentence as is. Normally, when accepting string input from
the user, quotemeta() or \Q
must be used.