hydrocomputer
Programmer
I want to write a generic web extraction subroutine in perl. To do so, I want to:
1. find the first pattern (easy)
2. toss everything before it (easy)
3. iteratively find successive occurrences of a patten of interest (easy)
Then comes the hard part. Given an arbitrary pattern containing parens, I want to build a list of what was found, like:
if ($line =~ /$pat/) {
$list = [$1,$2,$3,...];
push(@found, $list);
}
Except that I'd like the number of matches to be variable. Short of building dynamic strings and evaluating them, is there any clean way of doing this in PERL? Is there a regex variable for the maximum number of patterns extracted?
thanks!
1. find the first pattern (easy)
2. toss everything before it (easy)
3. iteratively find successive occurrences of a patten of interest (easy)
Then comes the hard part. Given an arbitrary pattern containing parens, I want to build a list of what was found, like:
if ($line =~ /$pat/) {
$list = [$1,$2,$3,...];
push(@found, $list);
}
Except that I'd like the number of matches to be variable. Short of building dynamic strings and evaluating them, is there any clean way of doing this in PERL? Is there a regex variable for the maximum number of patterns extracted?
thanks!