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

"what prompted the author to return the results as an array with a hash as the second item? "

Where do you get that from?

"It's kind of confusing me. For a start, if it's a hash, shouldn't that be ..."

It's not a hash, where do you get hash from?

And why is print "$tag @{[%links]}\n"; scary to you?

More than anything it's kind of silly to me, cause all that sub needs to be is  print "@_\n";

update:
"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.".

AFAIK, no attributes are ever "links". Duplicate SRC attributes wouldn't be valid HTML, and one of the 2 would be ignored. It's like this, if anyone writing HTML wants anybody to somewhat accurately interpret it, well, he's gotta write valid HTML, right? (right)

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

Replies are listed 'Best First'.
Re: Re: Why Would HTML::LinkExtor return a <I>hash</I> of attributes?
by Cody Pendant (Prior) on Aug 19, 2002 at 05:33 UTC
    Isn't it a hash?

    Why does it have "key => val, key => val" if it isn't?

    Plus, if it isn't, why does the sub grab it as:

    my($tag, %links) = @_;
    if it isn't a hash?

     all that sub needs to be is print "@_\n" Try it. You get both the "HREF" and the thing it's a link to. I don't want to extract "HREF" 5,000 times do I?
    --

    ($_='jjjuuusssttt annootthheer pppeeerrrlll haaaccckkeer')=~y/a-z//s;print;
       => Is a fancy comma (,). It allows you to say
      print I => AM => NOT => QUOTING => WORDS => TIMES => 5;
      which would print IAMNOTQUOTINGWORDSTIMES5

      Using this fancy comma doesn't make a hash. A hash is a "data structure", and I => AM => NOT => QUOTING => WORDS => TIMES => 5 is a list.

      Now you can do many things with lists. You can create arrays ( also data structures )

      my @ARRAY = ( I => AM => NOT => QUOTING => WORDS => TIMES => 5 );
      and you can create hashes
      my %HASH = ( I => AM => NOT => QUOTING => WORDS => TIMES => 5 );
      . Do you follow now?

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