in reply to Problems splitting HTML in to hash table
Either use the elements of the list or access the indexes like so:for (@list) { $list[$count]; #yadda yadda $count++; }
Second - use a Parser! If HTML::LinkExtor won't do the job then try HTML::TokeParser or HTML::Parser. You did not specify what you are trying to accomplish with this code, so i can't really help you much more. Even though you have managed to get this technique to work on other pages, i still question it's robustness. Trust me, use a parser - it might even be as simple as:for my $count (0..$#list) { $list[$count]; #yadda yadda }
use strict; use Data::Dumper; use HTML::TokeParser; my $data = do {local $/;<DATA>}; my $parser = HTML::TokeParser->new(\$data); my %hash; while (my $tag = $parser->get_tag('a')) { $hash{$tag->[1]->{href}}++; } print Dumper \%hash; __DATA__ <tr align="left" valign="top"> <td align="left" valign="top"> <table C +ELLPADDING="0" CELLSPACING="0"><tr><td> <a href="page.cfm?objectid=11 +933900&method=full&siteid=50144" CLASS="smallteaserpic">Costly false +alarms</a><BR> <font CLASS="headtypea"> A new policy aimed at tackling the huge waste of police time attending + false security alarm calls is to be introduced this week <a href="pa +ge.cfm?objectid=11933900&method=full&siteid=50144">more</a> </font> </td></tr></table> <p> <table CELLPADDING="0" CELLSPACING="0"><tr><td> + <a href="page.cfm?objectid=11933890&method=full&siteid=50144" CLASS= +"smallteaserpic">Mindless yobs terrorise OAP's</a><BR>
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (jeffa) Re: Problems splitting HTML in to hash table
by Popcorn Dave (Abbot) on Jun 11, 2002 at 17:56 UTC | |
by jeffa (Bishop) on Jun 11, 2002 at 19:20 UTC | |
by Popcorn Dave (Abbot) on Jun 12, 2002 at 02:37 UTC |