我有一个类似模式的长htdoc,继续这样:
<td class="MODULE_PRODUCTS_CELL " align="center" valign="top" height="100">
<table width="100" summary="products"><tr>
<td align="center" height="75">
<a href="/collections.php?prod_id=50">
<img src="files/products_categories50_t.txt" border="0" alt="products" /></a><\br>
</td>
</tr>
<tr>
<td align="center">
<a href="/collections.php?prod_id=50"><strong>Buffer</strong><br />
</a>
<td>
</tr></table>
</td>
Run Code Online (Sandbox Code Playgroud)
在上面的html中我想提取:
collections.php?prod_id=50 files/products_categories50_t.txtBuffer我已经尝试过这段代码,
#!/usr/local/bin/perl
use strict;
use warnings;
my $filename = 'sr.txt';
open(FILENAME,$filename);
my @str = <FILENAME>;
chomp(@str);
#print "@str";
foreach my $str(@str){
if ($str =~/<td class(.*)<a href(.*?)><\/td>/) {
print "*****$2\n";
}
}
Run Code Online (Sandbox Code Playgroud)
此代码是试用版.然而,它只带来最后一次出现,而不是每次出现.为什么?