A few things:
- The /s flag indicates that the dot is presumed to include newlines.
- The /g flag indicates that this pattern is going to return a list of all matches.
So, in effect, you will only have a single $1 at the end, but you wouldn't use those. Instead:
my @grabbed = $page =~ m#<b>(.*?)</b>#sig;
A few changes. First, dot-star will grab as much as it can, being
greedy. This isn't good since you'll get everything from the first
<B> tag to the last close, or in other words, one big match instead of smaller ones. The question mark causes the regular expression to find the shortest match instead.
The
/i modifier also catches tags that are capitalized. Another trick is to use the hash mark instead of slash, so that you don't have to escape your slashes.
If you're feeling more adventuresome, you might want to check out
HTML::Parser.