LMPX.COM |
Home | Linux | Mysql | PHP | XML | ||
|
|
|||
From: Gunnar Hjalmarsson Date: Tue Apr 8 07:50:22 2008 Subject: Re: Extracting TD's from a Text File (Regex Help).
sara.samsara@gmail.com 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
| Navigate in group perl.beginners.cgi at sever nntp.perl.org | |
| Previous | Next |
| © No Copyright You are free to use Anything |
Site Maintained by PHP Developer
Powered By PHP Consultants |