I want to print some dates from a site with a structure like this:
<tr><td><b><a href="/calendar.*?=\w+">(.*?)</a></b></td>
<td align=".*?"/date/(\d+)-(\d+)/">.*?</a> <a href="/year/\d+/">(\d+)</a></td>
<td>(.*?)*</td></tr>
etc.
my $country = $1;
my $month = $2;
my $day = $3;
my $year = $4;
my $event = $5;
I need to extract only those where the $country is ‘USA’ but if I use the while statement the code loops endlessly through the first match. How do I rework the script to extract each found USA date?
sub getSpec {
my $line = shift;
my $site = getSite($line);
while ($site =~ s/.../) {
my $country = $1;
my $month = $2;
my $day = $3;
my $year = $4;
my $event = $5;
if ($country =~ /USA/i) {
print $month.$date.$year.$country.$event."\n";
}
}
}
A global match should make it for you:
For details, look in the documentation.