http://qs321.pair.com?node_id=510462

0xbeef has asked for the wisdom of the Perl Monks concerning the following question:

I have encountered the following interesting problem. My original intention was to install Net::SSH::Perl using cpan. cpan will automatically download and attempt to install Math::Pari, but I seem to have to update all modules (e.g. /usr/lib/perl5/site_perl/5.8.6/Crypt/DH.pm) to use Pari instead of GMP manually:

use Math::BigInt lib => "GMP";

to

use Math::BigInt lib => "Pari";

Is there a more elegant way of switching to PARI than this?

0xbeef

Replies are listed 'Best First'.
Re: Net::SSH::Perl and PARI
by PodMaster (Abbot) on Nov 22, 2005 at 13:56 UTC
    but I seem to have to update all modules (e.g. /usr/lib/perl5/site_perl/5.8.6/Crypt/DH.pm) to use Pari instead of GMP manually:
    No you don't. All you have to do is start your program with
    use Math::BigInt qw' lib Pari ';

    See MATH_LIBRARY in Math::BigInt docs.

    The fact that modules like Crypt::DH and Crypt::DSA::KeyChain specify which library they prefer should have no effect on which library is actually used.

    update: actually, you should use Math::BigInt qw' lib Pari '; last (after use Net::SSH...).

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      Hmm, this doesn't work for me. If I manually change DH.pm to use Math::BigInt lib => "GMP"; and then make the changes to my script as per your suggestion, my execution time drastically increases (from 5 to 25 seconds) until I revert the change to DH.pm.

      0xbeef

        I'd say its working ;)

        If you've got both Math::BigInt::GMP and Math::BigInt::Pari installed, you've effectively loaded both of them, and DH.pm is using Math::BigInt::Pari since it was loaded last :)

        See 16032 lib GMP versus lib PARI versus lib GMP,PARI.

        For now, you should only install one of them.

        MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
        I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
        ** The third rule of perl club is a statement of fact: pod is sexy.