in reply to Subroutine not working quite right

Your problem is the nested subroutine. It's a named subroutine, and it gets compiled once. It's not a reference to a sub, so no closure is created - and that's exactly what you want here. You're likely to find that the following works better:
sub extractlinks { my($url, $linktype) = @_; my @sublinks = (); my $callback = sub { my($tag, %attr) = @_; return if $tag ne $linktype; push(@sublinks, values %attr); } my $p = HTML::LinkExtor->new($callback); my $res = $ua->request(HTTP::Request->new(GET => $url), sub {$p->parse($_[0])}); my $base = $res->base; return map {$_ = url($_, $base)->abs; } @sublinks; }

-- Abigail