Re: Extracting TD's from a Text File (Regex Help).

[email protected] ("Wiggins d'Anconia")
Newsgroups perl.beginners.cgi
Organization http://danconia.org
Message-ID <[email protected]>
[email protected] wrote:
> ################ TEXT FILE ##################
> <td class="PhorumTableRowAlt thread"  style="padding-left: 0px">
>         
>             <a href="http://mysite.com/link/here_goes?id=239">LINK</a>
> 
>     &nbsp;<span class="PhorumNewFlag"></span></td>
> 
>  <td class="PhorumTableRowAlt" nowrap="nowrap" width="150">
>   <a href="http://mysite.com/link/here_goes?id=239">LINK</a> </td>
>     <td class="PhorumTableRowAlt PhorumSmallFont" nowrap="nowrap" width="150">06/11/2007 12:29AM
>  </td>
> </tr>
> ############################################
> 
> The text file contains hundreds of tds structure like above. All I need is to extract the td with class "PhorumTableRowAlt thread". I have tried every possible option, but finally I am coming to you for any Regex for it? TIA.
> 
> HERE IS WHAT I AM DOING:
> 
> pen(TXT, "links.txt") or die "Unable to open file";
> my @links = <TXT>;
> close (TXT);
> foreach my $link(@links) {
> if ($link =~ m|<td class="PhorumTableRow thread" style="padding-left: 0px">(.*?)</td>|gsi) {
> print "$1";}
> }
> 
> 
> 
> But NOTHING coming up. No results.
> 
> Thanks for any help.
> 
> Sara.
> 

Parsing HTML with regexes is just a bad idea. Try a module from CPAN,
I've had good luck with HTML::TokeParser::Simple,

http://search.cpan.org/perldoc?HTML::TokeParser::Simple

http://danconia.org
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.