koonom wrote:
#!/usr/bin/perl -w

use LWP::Simple;
use HTML::LinkExtor;

$URL = get("http//www.nytimes.com");

#open (FILE, ">file.txt");

$LinkExtor = HTML::LinkExtor->new(\&link);

Jeff already pointed out your error here^^.

$LinkExtor->parse($URL);

sub links
{
    ($tag, %links) = @_;
    if ($tag eq "a"){
        foreach $key (keys %links){
            if ($key eq "href"){
                print "links{$key}\n";
            }
        }
    }

Hash keys are unique so you don't need a loop there:

    if ( $tag eq 'a' ) {
        if ( exists $links{ href } ) {
            print "$links{href}\n";
        }
    }

}


John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to