Perl CPAN模块对象方法未找到错误

san*_*jay 3 perl cpan

我正在尝试使用CPAN模块: Math::Vector::Real::Neighbors

我看到以下错误消息:

无法通过/usr/local/share/perl/5.14.2/Math/Vector/Real/Neighbors.pm第12行中的包"Math :: Vector :: Real"找到对象方法"box".

所以,我进入包中看到这个: my ($bottom, $top) = Math::Vector::Real->box(@_);

接下来,我进入Real.pm包裹:/usr/local/share/perl/5.14.2/Math/Vector/Real.pm

我看到盒子例程存在于其中: sub box {...

知道为什么错误可能会出现吗?

i a*_*ien 7

您需要添加use Math::Vector::Real到脚本的顶部以使Math :: Vector :: Real :: Neighbors工作.以下代码按预期运行:

use strict;
use warnings;

use Math::Vector::Real;
use Math::Vector::Real::Neighbors;
use Math::Vector::Real::Random;

my @v = map Math::Vector::Real->random_normal(2), 0..1000;
my @nearest_ixs = Math::Vector::Real::Neighbors->neighbors(@v);
Run Code Online (Sandbox Code Playgroud)

但请注意,如果没有使用Math :: Vector :: Real的行,它就无法工作.