perl错误:'Statistics :: Descriptive'中没有'new'方法

Ken*_*Ken 0 perl perl-module

我使用cpan安装了"Statistics :: Descriptive"模块然后测试了这个例子:

use Statistics::Descriptive;
$stat = new Statistics::Descriptive;
$stat->AddData(1,2,3,4);
Run Code Online (Sandbox Code Playgroud)

但它显示错误:Can't locate object method "new" via package "Statistics::Descriptive" at ...我在Linux Ubuntu中使用Perl版本5.10.1以及最新的Statistics :: Descriptive,就像cpan告诉我的那样.

我尝试使用activestate perl的Windows,它的工作原理.

你知道为什么我在Linux上运行时遇到这个错误吗?谢谢.

yst*_*sth 7

文档中看起来你需要做任何一件事

use Statistics::Descriptive;
my $stat = Statistics::Descriptive::Full->new();
Run Code Online (Sandbox Code Playgroud)

要么

use Statistics::Descriptive;
my $stat = Statistics::Descriptive::Sparse->new();
Run Code Online (Sandbox Code Playgroud)

正如所说的那样:"使用稀疏方法,没有数据存储,只有少数统计指标可用.使用完整方法,整个数据集将被保留,并且可以使用其他功能."

也许你在Windows上有一个旧版本.旧版本有一个未记录的顶级new()方法.