The matching operator has several options that enhance its utility, similar to substitution. The most useful option is probably the capability to ignore case and to create an array of all matches in a string. The options are:
m -- This option treats the string as multiple lines. Perl does some optimization by assuming that $_ contains a single line of input. If you know that it contains multiple newline characters, use this option to turn off the optimization.
All options are specified after the last pattern delimiter. For instance, if you want the match to ignore the case of the characters in the string, you can do this (match4.pl):
$_ = "AAA BBB AAA"; print "Found bbb\n" if m/bbb/i;
This program finds a match even though the pattern uses lowercase and the string uses uppercase because the /i option was used, telling Perl to ignore the case.
The result from a global pattern match can be assigned to an array variable or used inside a loop. This feature comes in handy after you learn about meta-characters in the section called "How to Create Patterns" later in this chapter.
For more information about the matching options, see the section, "Pattern Examples" later in this chapter.