say your text is in a string (or an array of strings) then I would use grep and map :-) to get a list of all matches nicely formatted as list items, but for sure there is an easier way which refuses to come to my mind now :-)
perhaps this might do :-)
# the substitution is none in effect, it just digs around
$page2 =~ s|<title>(.*)</title>|${my_count(\$1)}|gi;
my matches = ();
sub my_count {
my $occurance = shift;
push @matches, ${$occurance} ;
return $occurance;
}
# see what we've got
foreach (@matches) {
print '<li>'.$_.'</li>'."\n"; # just to format the output :-)
}
Have a nice day
All decision is left to your taste
Update
fixed stupid error in the substitutional part where I inserted the '<title>' again.
|