note
a
Just a point here - something I finally got only after a number of rereadings of the section in J. Friedl's excellent [http://www.oreilly.com/catalog/regex2/index.html|Mastering Regular Expressions (O'Reilly)] the /m and /s are a little more complicated.<br>
/m: better remembered as 'multi' mode - affects 'multiple' (2) meta chars, the anchors (^ and $)<br>
/s: 'single' mode - affects one meta char, the dot '.'
<P>
/s changes the dot's normal definition - match any char <i>except</i> a new line (\n).
In single mode the dot can match \n too which allows regex phrases like:<br>
.*<p>
to match across the end of line. That all it does and so its why the "item.*" in your example matches the end of line.<br>
/m changes the ^ and $ anchors from absolute beginning and end of string to match beginning and end of a line, as marked by new line chars. Which is useful w/ the '/g' option, for example:
<code>
local $/ = undef;
my $whole_file = <>; # slurp
while ( $whole_file =~ /^(.*)$/mg ) {
# process line by line
print "Got: $1\n";
}
</code>
Not a useful snippet but ... two notes - the '\n' on the print stmt and notice the diff if you put an 's' in the match options
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-15571">
<p><i>a</i>
</div></div>
558260
558521