in reply to Problems with matching and metacharacters

Not sure if this is what you're looking for, but quotemeta will return its argument string with all metacharacters quoted (preceded by backslashes, in case that's relevant). Take a look at perlfunc.

HTH