in reply to Pattern Matching

This should do it... I got surprised the $1 behaves differently if you loop through the array returned by /g matching, or if you stick the result of =~ in a while loop. Updated with various thoughts about this.
use warnings; use strict; use Data::Dumper; # for debugging local $/ = ""; # input separator was newline, but now it's gone -> slu +rp mode. my $html; while (<DATA>) { $html = $_; } print "Html: $html\n\n"; # just to check that this worked... it works. #Don't do this, you can't use the $1, $2 type special variables. my @matches = $html =~ m|(<B><P ALIGN=CENTER>(.+)</B></FONT>)|g; # use + | as regex delimitor to avoid leaning toothpick syndrome. print "Dumper\n" . Dumper(\@matches); # bit o debugging #Do this. Then you can access the special vars. while ($html =~ m|(<B><P ALIGN=CENTER>(.+)</B></FONT>)|g) { print "match $2\n"; # don't know why this works. $1 doesn't work. + Hm... } #outputs #match blah #match foo #match gah #$line =~ m/<B><P ALIGN\=CENTER>(.+)<\/B><\/FONT>/gm; #my $bit_i_want=$1; __DATA__ <B><P ALIGN=CENTER>blah</B></FONT> <B><P ALIGN=CENTER>foo</B></FONT> <B><P ALIGN=CENTER>gah</B></FONT>
Maybe you should be using HTML::TokeParser to do html matching, regex matching on html doesn't scale too well.