in reply to How can I find the links in HTML tags?
The following 4-liner uses HTML::Parser; it was both easy to code and correct — unlike any regex solution you're likely to see.
As coded, it assumes you're looking only for href links within anchor tags, but it is easily modified for other things, such as img tags.
use HTML::Parser; my $p = HTML::Parser->new( api_version => 3 ); $p->handler( start => sub { printshift->{href} if shift eq 'a' }, 'tag +name,attr' ); local $/; $p->parse(<>); #Just another URI finder
|
|---|