dannoura has asked for the wisdom of the Perl Monks concerning the following question:
hi,
I'm trying to print out the href attribute of all links in a document but not succeeding for some reason. I keep getting the error:
Can't use string ("</a>")as a HASH ref while strict refs in useIt's probably some stupid mistake but I'm new to HTML::TokeParser and perl so bear with me. The code is:
#! c:\perl\bin -w use strict; use HTML::TokeParser; my $p = HTML::TokeParser->new(shift||die); while (my $token = $p->get_token) { print $token->[2]{'href'}, "\n" if ($token->[1] eq 'a'); }
And the relevant part of the html is:
<td nowrap> <font size="-1"><a href="/home.cfm" target="_top" class=" +novisit">Home</a> | <a href="/SpecimenSearch.cfm" target="_top" clas +s="novisit">Specimen Search</a>
-----------------------------------
Any comments about coding style are welcome.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: HTML::Tokeparser and $attr problem
by Mr. Muskrat (Canon) on Apr 24, 2004 at 18:10 UTC | |
by dannoura (Pilgrim) on Apr 24, 2004 at 18:13 UTC | |
Re: HTML::Tokeparser and $attr problem
by Rex(Wrecks) (Curate) on Apr 24, 2004 at 18:29 UTC | |
Re: HTML::Tokeparser and $attr problem
by Ovid (Cardinal) on Apr 25, 2004 at 07:22 UTC |
Back to
Seekers of Perl Wisdom