I have the following precompiled regexp:
$test_regexp = qr/url="(http:\/\/downloads\.bbc\.co\.uk\/podcasts\/wor
As you can see, I have 2 capture groups built into this match. One captures the complete URL, the other capture gets just the filename itself.
The webpage I use this particular regexp on may contain multiple valid matches on the same line. I would like to capture both the complete URL and the filename for each one.
If it matters (and I don't believe it does), the precompiled regexp is passed to a function that dumps the webpage to a file, opens the file with the TEMP_XML_FILE handle, and searches for the $test_regexp matches on each line.
Right now I have this:
if ((@complete_url, @filename) = ($_ =~ /$test_regexp/g))
printf("found %d matches\n", scalar(@filename));
for ($i = 0; $i < @filename; $i++)
printf("filename = %s, complete_url = %s\n", $filename[$i]
The problem is that the printf statement is reporting 0 matches. After reading through the entire file, I want the @complete_url array to contain the complete list of URLs, and the @filename array to contain the complete list of filenames. How can I accomplish this? I realize I might be able to capture just the complete url and derive the filenames from it in a separate step, but for the sake of this discussion how can I capture both the filenames and urls into their respective arrays when there could be multiple matches per line?