Problemas con el análisis de datos de la tabla en perl
Tengo un htdoc largo de patrón similar que sigue así:
<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>
En el html anterior quiero extraer:
collections.php?prod_id=50
files/products_categories50_t.txt
Buffer
He intentado este código para empezar,
#!/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";
}
}
Este código es de prueba. Sin embargo, solo trae la última ocurrencia y no cada ocurrencia. ¿Por qué?