in reply to Re: Re: Why Would HTML::LinkExtor return a hash of attributes?
in thread Why Would HTML::LinkExtor return a hash of attributes?

"but surely the guy is intending it to be used as a hash?"

I'm not a mindreader. HTML::LinkExtor is a pretty mature module, and I doubt the interface should/will change.

You can certainly try to persuade the guy (perlsonally i'd rather just write HTML::LinkExtractor which would do all the things you say here, but would also extract the link text (stuff in between <a ..> </a> tags).

" One useful attribute of it being a hash would be to clobber incorrect HTML where a link had two HREFs. "

You don't have to worry about that (when in doubt, test).

use HTML::LinkExtor; my $p = new HTML::LinkExtor( sub { print "@_\n" }, ); $p->parse( q{ <a href="BUTTER" href="SCOTCH"> <img src="AND" src="PEANUTS"> }); __END__ a href SCOTCH img src PEANUTS

____________________________________________________
** The Third rule of perl club is a statement of fact: pod is sexy.

Replies are listed 'Best First'.
Re: Re: Re: Re: Why Would HTML::LinkExtor return a hash of attributes?
by Cody Pendant (Prior) on Aug 19, 2002 at 23:52 UTC
    I don't want to persuade the guy to change. I've long ago had my question answered, i.e. "why isn't there just a single attribute for each tag?", because it's been noted that there are indeed instances where there are two or more attributes which constitute a link in one tag.
    --
    ($_='jjjuuusssttt annootthheer pppeeerrrlll haaaccckkeer')=~y/a-z//s;print;