我有这个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的类定义中。

最佳答案

您缺少a$

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

08-25 21:48