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

I recently installed installed perl (v5.23.3) , now my old scripts wont work because it complains about modules, but those modules were installed and if I try reinstalling it says

cpan -i Net::OpenSSH CPAN: Storable loaded ok (v2.51) Reading '/root/.cpan/Metadata' Database was generated on Tue, 09 Feb 2016 14:53:50 GMT CPAN: Module::CoreList loaded ok (v5.20160120) Net::OpenSSH is up to date (0.70). #>perl install_web.pl Can't locate Net/OpenSSH.pm in @INC (you may need to install the Net:: +OpenSSH module) (@INC contains: /usr/local/perl-5.23.3/lib/site_perl/ +5.23.3/x86_64-linux /usr/local/perl-5.23.3/lib/site_perl/5.23.3 /usr/ +local/perl-5.23.3/lib/5.23.3/x86_64-linux /usr/local/perl-5.23.3/lib/ +5.23.3 .) at install_web.pl line 5. BEGIN failed--compilation aborted at install_web.pl line 5.

How do I install the modules in the new location or have the metadata read in the new location? thank you

Replies are listed 'Best First'.
Re: Cant find modules after upgrade
by 1nickt (Canon) on Feb 09, 2016 at 17:14 UTC

    Good example of why it's often wise to leave your system Perl alone and install new versions into their own location. See perlbrew for the recommended way to do this.

    Also note that the above is even more advisable if you are going to upgrade to a Perl that is a development version, as is the one you installed, version 5.23.3 .

    The way forward always starts with a minimal test.
Re: Cant find modules after upgrade
by jhourcle (Prior) on Feb 09, 2016 at 18:34 UTC

    The problem is that cpan will still be using whatever version of perl that you installed it with. You can check which version it's trying to install modules for by calling cpan --version.

    You'll get a message like:
    $ cpan --version /usr/bin/cpan version 1.61 calling Getopt::Std::getopts (version 1.07 +[paranoid]), running under Perl version 5.18.2. [Now continuing due to backward compatibility and excessive paranoia +. See 'perldoc Getopt::Std' about $Getopt::Std::STANDARD_HELP_VERSION +.]

    To make sure that you're calling the CPAN shell with a specific version, you should call it using the specific version of perl, rather than the 'cpan' script: /path/to/perl -MCPAN -e shell.

    Also note that you can run into the same problem with cpanm.

      thank you using the cpan from the new location worked.
Re: Cant find modules after upgrade
by neilwatson (Priest) on Feb 09, 2016 at 16:37 UTC