开发者

perl error: no 'new' method in 'Statistics::Descriptive"

I installed the "Statistics::Descriptive" module using cpan then test the example: 开发者_开发百科

use Statistics::Descriptive;
$stat = new Statistics::Descriptive;
$stat->AddData(1,2,3,4);

But it shows error: Can't locate object method "new" via package "Statistics::Descriptive" at ... I am doing it in Linux Ubuntu with Perl version 5.10.1 and the newest Statistics::Descriptive as what cpan tells me.

I tried on windows using activestate perl and it works.

Do you have any idea why I got this error when running in Linux? Thanks.


From the documentation it looks like you need to do either

use Statistics::Descriptive;
my $stat = Statistics::Descriptive::Full->new();

or

use Statistics::Descriptive;
my $stat = Statistics::Descriptive::Sparse->new();

As is says: "With the sparse method, none of the data is stored and only a few statistical measures are available. Using the full method, the entire data set is retained and additional functions are available."

Perhaps you have an older version on windows. Older versions had an undocumented top level new() method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜