2

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?

billa
  • 23
  • 1
  • 4
  • Have you installed the DBI module for your version of perl? Because the system module isn't going to work for you. – Etan Reisner Dec 10 '14 at 16:21
  • How to install DBI module for my version of perl or how to check if already some DBI module is present and link it? – billa Dec 10 '14 at 16:25
  • Why did you install your own version of perl to begin with? What version of CentOS is this (as far as I know the newest perl available on CentOS is 5.16). – Etan Reisner Dec 10 '14 at 16:26
  • I have installed it to use the latest version available.The version of CentOS is CentOS release 6.5 (Final). – billa Dec 10 '14 at 16:32
  • @Sobrique is that the only command or do I need to run make after that.If it is installed how do I check things about it like-installed or not,version,path? – billa Dec 10 '14 at 16:40
  • Perl has an installer/builder all packaged together. It'll install somewhere suitable - usually in a 'site perl' directory which is in your `@INC` path. – Sobrique Dec 10 '14 at 17:17
  • @Sobrique I have installed it and yes,it is present in site_perl folder.Can you also guide me how to check for all installed versions of perl and its modules,how to switch between them while executing a program? – billa Dec 10 '14 at 17:35
  • Usually: default perl is `/usr/bin/perl`. New perl is `/usr/local/bin/perl`. (But depends on where you installed it when you installed it). Replacing system perl isn't a good idea unless you know what you're doing. – Sobrique Dec 10 '14 at 21:56
  • 2
    "perl 5.19 was present by default" - I really don't think that's the case. Perl 5.19 has never shipped as the default version with Centos (or any sane Linux distribution). Perl 5.19 is a development version. It should never go anywhere near a production server. – Dave Cross Dec 11 '14 at 10:14
  • Stack Overflow uses [the *Markdown* formatting syntax](http://daringfireball.net/projects/markdown/basics) to format posts. Please use it in preference to bare HTML. Check [Markdown Editing Help](http://stackoverflow.com/editing-help) for assistance. – Borodin Dec 11 '14 at 12:14
  • @DaveCross I'm not sure about the 5.19,how do I check the system default perl version?Now perl -v shows only 5.20! – billa Dec 12 '14 at 07:14
  • If you haven't overwritten the system Perl then you can get the version from `/usr/bin/perl -v`. Otherwise, you can try `rpm -q perl`. – Dave Cross Dec 12 '14 at 09:17
  • @DaveCross yes,it's not 5.19,checked with /usr/bin/perl -v,the default version is 5.10,that was a mistake,edited the original post too! – billa Dec 12 '14 at 13:52

1 Answers1

2

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 to resolve this error so that I can use DBI module?

Community
  • 1
  • 1
Chankey Pathak
  • 21,187
  • 12
  • 85
  • 133