无法定位对象方法"链接"通过包" mech"

时间:2014-09-23 00:30:39

标签: html perl http www-mechanize

我有这个perl代码:

#!/usr/bin/perl
use warnings;
use strict;

require WWW::Mechanize;

my $baseurl = $ARGV[0];

my $mech;
$mech = WWW::Mechanize->new();
$mech->get($baseurl);

my @links = mech->links();
foreach my $link (@links) {
    print "link->url\n";
}

我收到错误:

Can't locate object method "links" via package "mech" (perhaps you forgot to load "mech"?) at ./so.pl line 13.

我很难过;这绝对是CPAN的课程定义。

1 个答案:

答案 0 :(得分:1)

您错过了$

my @links = $mech->links();