RedRobotHero
Technical User
I'm trying to harvest links from an html page. (Not for anything nefarious, I assure you.) This is the code I've used to match the links:
My trouble is this will only match once per line. How would I acquire all of the links on one line, instead of just the first?
(If all else fails, I'm going to take the lines and split them on the whitespace. But somehow I think this must be a common enough problem that there's a simpler way of doing it.)
Code:
foreach (@page) {
if (/href=\s*['"]?([^\s'"]*)['"]?/)
{
push @links, $1;
}
}
My trouble is this will only match once per line. How would I acquire all of the links on one line, instead of just the first?
(If all else fails, I'm going to take the lines and split them on the whitespace. But somehow I think this must be a common enough problem that there's a simpler way of doing it.)