Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Why Would HTML::LinkExtor return a hash of attributes?

by Arien (Pilgrim)
on Aug 19, 2002 at 05:50 UTC ( [id://191088]=note: print w/replies, xml ) Need Help??


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

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.

Well, <object> has the attributes classid, codebase, data, and archive (a space seperated lis of URIs). And even <img> could have multiple attributes that link: src, longdesc, and usemap.

— Arien

Replies are listed 'Best First'.
Re: Re: Why Would HTML::LinkExtor return a hash of attributes?
by Cody Pendant (Prior) on Aug 19, 2002 at 06:01 UTC
    <img> could have multiple attributes that link: src, longdesc, and usemap.
    Aha!

    Now that makes sense. I bet I could have figured it out if I'd thought a bit longer. I'm so lazy.

    Thanks for your help, podmaster, but surely the guy is intending it to be used as a hash?

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

    ($_='jjjuuusssttt annootthheer pppeeerrrlll haaaccckkeer')=~y/a-z//s;print;
      "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.

        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;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://191088]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2025-02-09 02:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (95 votes). Check out past polls.