perlsubroutineroutines

Routine in module is Undefined subroutine in perl


I have just installed the Crypt::Random module as well as all the dependencies such as Math::Pari. There are three routines in Crypt::Random and I don't know why perl is calling them 'undefined subroutine'. Thanks to whoever knows what is wrong. Here are the routines (specifically defined in the module), and I chose small arguments for them to see if they work:

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.

Solution

  • Crypt::Random does not export any methods by default.

    Instead you must explicitly import them:

    $ 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)"