Date sent: Wed, 27 May 2009 16:50:41 +0800 Subject: Pattern match question From: Á÷Ë(R)`Oô <aoi...@gmail.com> To: beginners@perl.org
> Hi, All: > > I want to parse data from a HTML page, data like: > > <tr > > > <td valign="top"> > YEMEN > </td> > <snipped> > ===================================== > I want to match one <tr>...</tr> pair. > > my code : > > my $pattern = "(<tr (.|\\n)*<\\\/tr>)"; > my $match; > while($data =~ /$pattern/g){ # $data has the content above > $match = $&; > print $match; > } > > but I got the whole matches instead of one <tr>...</tr> pair each loop. > > Do you guys have any ideas? Yes. Do not do that. There are modules for this kind of things. Parsing HTML is not as simple as you seem to think. In this case you want HTML::TableExtractor. Or maybe HTML::Parser. Jenda ===== je...@krynicky.cz === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/