Is it possible to iterate through a regular expression's results?
For example, if I have
Code:
foreach (@lines) {
print STDOUT "checking line: $_\n";
if(/.*(http:\/\/.*\.mp3).*/) {
print STDOUT "***********Found REMOTE file: $1\n";
$shortfilename = substr($1, rindex($1, "/")+1, length($1));
$prospectiveFiles{$shortfilename} = $1;
}
}
My initial assumption was that there would be just one URL per line. However, this has proved not to be the case in some of my test files...there's more than one, and I don't know how many there could be. Using just straight $1 is right out because of that...that line will have to change to a loop, which I hope will iterate through all of the results.
Is there a way to find out how many results were returned, and then to iterate through them?
Thanks!