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

[email protected] (Gunnar Hjalmarsson)
Newsgroups perl.beginners.cgi
Message-ID <[email protected]>
[email protected] wrote:
> All I need is to extract the td with class "PhorumTableRowAlt thread".

<snip>

> pen(TXT, "links.txt") or die "Unable to open file";
> my @links = <TXT>;
> close (TXT);
> foreach my $link(@links) {

While the substring of interest spans over multiple lines, you are 
dealing with one line at a time. Hence it can never match.

> if ($link =~ m|<td class="PhorumTableRow thread" style="padding-left: 0px">(.*?)</td>|gsi) {

There is no such class in the extract you posted.

     open my $TXT, '<', 'links.txt' or die "Unable to open file: $!";
     my $links;
     {
         local $/;           # slurp the whole thing
         $links = <$TXT>;    # into a scalar
     }
     while ( $links =~
       m|<td\s+class="PhorumTableRowAlt thread".*?>(.+?)</td>|gsi ) {
         print "$1\n";
     }

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
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.