Cody Pendant has asked for the wisdom of the Perl Monks concerning the following question:
You can see the full documentation at http://search.cpan.org/author/GAAS/HTML-Parser-3.26/lib/HTML/LinkExtor.pm if you want to, but I'm just wondering what prompted the author to return the results as an array with a hash as the second item?
Here's the relevant section:
$p->links Returns a list of all links found in the document. The returned values will be anonymous arrays with the follwing [sic] elements: [$tag, $attr => $url1, $attr2 => $url2,...]
It's kind of confusing me. For a start, if it's a hash, shouldn't that be
instead?[$tag, {$attr => $url1, $attr2 => $url2,...}]
And more to the point, I'm racking my not-inconsiderable knowledge of HTML to try and find a situation where a single tag could have two or more attributes which were links.
Apart from anything else, this structure leads to scary dereferencing being needed like this:
$p = HTML::LinkExtor->new(\&cb, "http://www.perl.org/"); sub cb { my($tag, %links) = @_; print "$tag @{[%links]}\n"; }
Maybe
isn't scary to you but it is to me...@{[%links]}
($_='jjjuuusssttt annootthheer pppeeerrrlll haaaccckkeer')=~y/a-z//s;print;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Why Would HTML::LinkExtor return a hash of attributes?
by PodMaster (Abbot) on Aug 19, 2002 at 05:24 UTC | |
by Cody Pendant (Prior) on Aug 19, 2002 at 05:33 UTC | |
by PodMaster (Abbot) on Aug 19, 2002 at 05:44 UTC | |
|
Re: Why Would HTML::LinkExtor return a hash of attributes?
by Arien (Pilgrim) on Aug 19, 2002 at 05:50 UTC | |
by Cody Pendant (Prior) on Aug 19, 2002 at 06:01 UTC | |
by PodMaster (Abbot) on Aug 19, 2002 at 06:15 UTC | |
by Cody Pendant (Prior) on Aug 19, 2002 at 23:52 UTC |