How to Avoid Making Mountains while Escaping Special Characters
You want to match this;
http://language.perl.com/faq/ . That's a real (useful) URL by the way. Hint. To match it, you need to do this:
/http:\/\/language\.perl\.com\/faq\//;
which should make the awful metaphor above clearer, if not
funnier. The slash, / , is not
normally a metacharacter but as it is being used for the regular expression
delimiters, it needs to be escaped. We already know that . is special.
Fortunately for our eyes, Perl allows you to pick your delimiter if you prefix it with 'm' as this example shows. We'll use a #:
m#http://language\.perl\.com/faq/#;
Which is a huge improvement, as we change / to # .
We can go further with readability by quoting everything:
m#\Qhttp://language.perl.com/faq/\E#;
The \Q escapes everything
up until \E or the regex delimiter (so
we don't really need the \E above). In this case #
will not be escaped, as it delimits the regex.