uni_j has asked for the wisdom of the Perl Monks concerning the following question:
use HTML::TokeParser; use WWW::Mechanize; use Data::Dumper; my $mech = WWW::Mechanize->new(); my $html; my $url = "http://ug.cal.dal.ca/"; my %url_dep; start(); sub start{ $mech->get($url); $html=$mech->content(); my $stream = HTML::TokeParser->new(\$html); while(my $token = $stream->get_token()){ if($token->[1] eq "div" && $token->[2]{id} eq "content-zone5"){ while(my $token = $stream->get_token("a")){ my $url_desc = $stream->get_phrase(); my $url = $token->[2]{href}; $url_dep { $url } = $url_desc; } } } print Dumper \%url_dep; foreach (sort { $a <=> $b } keys(%url_dep) ){ my $dep_url = $a; my $dep_name = $b; print $dep_url; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hash debugging.
by ikegami (Patriarch) on May 11, 2009 at 14:44 UTC | |
|
Re: Hash debugging.
by almut (Canon) on May 11, 2009 at 14:36 UTC | |
|
Re: Hash debugging.
by cnhackTNT (Novice) on May 11, 2009 at 15:05 UTC |