Table of Contents

Parentheses Again: OR

The real use for them. Precedence. Try this, and yes you can try it at home:

$_='One word sentences ? Eliminate. Avoid clichés like the plague.  They are old hat.';

while (/o(rd|ne|ld)/gi) {
        print "Matched $1\n";
}

Firstly, notice the subtle introduction of the or operator, in this case | , the pipe. What I really want to explain however, is that this regex matches o followed by rd, ne or ld. Without the parens it would be /ord|ne|ld/ which is definitely not what we want. That matches just plain ord, or ne or ld.