in reply to Re (tilly) 1: Why is this link parser only working the first time?
in thread Why is this link parser only working the first time?
Thanks very much. This is an excellent solution because the code change is limited to a single line.
What used to be:
... now becomes ...sub attachment_link_extractor { my ($tag, %attr) = @_; push(@links, values %attr) if (($tag eq 'a') && ($attr{href} =~ m/attachments/)); } my $p = HTML::LinkExtor->new(\&attachment_link_extractor);
The only part of the your suggested change that confused me was the need to put a semicolon after the bracket that closes the subroutine. I don't remember ever writing Perl that way before, but, I keep forgetting that the subroutine itself is part of an assignment statement.$attachment_link_extractor = sub { my ($tag, %attr) = @_; push(@links, values %attr) if (($tag eq 'a') && ($attr{href} =~ m/attachments/)); }; my $p = HTML::LinkExtor->new($attachment_link_extractor);
Dave Aiello
Chatham Township Data Corporation
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re (tilly) 3: Why is this link parser only working the first time?
by tilly (Archbishop) on Jan 20, 2001 at 15:31 UTC |