in reply to Extracting full links from HTML
Here's my go using HTML::TokeParser::Simple.
output:#!C:/Perl/bin/perl.exe use strict; use warnings; use HTML::TokeParser::Simple; my $html = q{ <a href="some.html"><img src="an_image.jpg"/></a> }; my $p = HTML::TokeParser::Simple->new(\$html); my $in_anchor; while (my $t = $p->get_token){ if ($t->is_start_tag('a')){ $in_anchor++; next; } if ($t->is_start_tag('img') and $in_anchor){ my $src = $t->get_attr('src'); print "$src\n"; $in_anchor = 0; } }
an_image.jpg
|
|---|