问题
I am using CentOS, and I have installed Perl 5.20 and Perl 5.10 was present by default.
I am using the Perl 5.20 version to execute the Perl code
I am trying to use the DBI module and get this error
[root@localhost ~]#perl -e 'use DBI;'
Can't locate DBI.pm in @INC (you may need to install the DBI module) (@INC contains: /usr/local/lib/perl5/site_perl/5.20.1/i686-linux /usr/local/lib/perl5/site_perl/5.20.1 /usr/local/lib/perl5/5.20.1/i686-linux /usr/local/lib/perl5/5.20.1 .) at -e line 1.
BEGIN failed--compilation aborted at -e line 1.
How to check for all installed versions of Perl?
How do I check whether the DBI or any module is installed?
How to resolve this error so that I can use DBI module?
回答1:
How to check for all installed versions of perl?
- As Sobrique suggested in comments, you should never touch system perl. I'd suggest using perlbrew. With perlbrew you can install different versions of perl from local user, and to check all installed versions of perl using perlbrew just do
$ perlbrew -l
.
how to switch between them while executing a program?
Install multiple perls
$ perlbrew -v install perl-5.20.0
$ perlbrew -v install perl-5.13.4
Switch between them
$ perlbrew switch perl-5.20.0
$ perlbrew switch perl-5.13.4
See this article for more details: Installing Multiple Perls with App::perlbrew and App::cpanminus
How do I check if DBI or any module is installed?
- How can I check if a Perl module is installed on my system from the command line?
How to resolve this error so that I can use DBI module?
What's the easiest way to install a missing Perl module?
A Guide to Installing Modules
来源:https://stackoverflow.com/questions/27405894/unable-to-locate-dbi-pm-module-in-perl