With respect to character matching, there are a few more points you need to know about. First of all, not all characters can be used ‘as is’ in a match. Some characters, called metacharacters, are
reserved for use in regexp notation. The metacharacters are
{}[]()^$.|*+?\
The significance of each of these will be explained in the rest of the tutorial, but for now, it is important only to know that a metacharacter can be matched by putting a backslash before it:
“2+2=4″ =~ /2+2/; # doesn’t match, + is a metacharacter
“2+2=4″ =~ /2\+2/; # matches, \+ is treated like an ordinary +
“The interval is [0,1).” =~ /[0,1)./ # is a syntax error!
“The interval is [0,1).” =~ /\[0,1\)\./ # matches
“#!/usr/bin/perl” =~ /#!\/usr\/bin\/perl/; # matches
Thanks
Manoj Chauhan
