模块中的例程是 perl 中的未定义子例程

Routine in module is Undefined subroutine in perl

我刚刚安装了 Crypt::Random module as well as all the dependencies such as Math::Pari。 Crypt::Random 中有三个例程,我不知道为什么 perl 会调用它们 'undefined subroutine'。感谢谁知道出了什么问题。以下是例程(具体定义在模块中),我为它们选择了小参数以查看它们是否有效:

C:\Users\Jlinne\Documents>perl -MCrypt::Random -E "say makerandom(100)"
Undefined subroutine &main::makerandom called at -e line 1.

C:\Users\Jlinne\Documents>perl -MCrypt::Random -E "say makerandom_itv(1, 1000)"
Undefined subroutine &main::makerandom_itv called at -e line 1.

C:\Users\Jlinne\Documents>perl -MCrypt::Random -E "say makerandom_octet(10)"
Undefined subroutine &main::makerandom_octet called at -e line 1.

Crypt::Random 默认不导出任何方法。

相反,您必须显式导入它们:

$ perl -MCrypt::Random=makerandom -E "say makerandom(100)"
$ perl -MCrypt::Random=makerandom_itv -E "say makerandom_itv(1, 1000)"
$ perl -MCrypt::Random=makerandom_octet -E "say makerandom_octet(10)"