4

When running a Perl Script that grabs content from an Oracle DB and exports the results into a CSV, I am getting this error when trying to run it via the command line:

Can't locate Text/CSV.pm in @INC (@INC contains:
/usr/lib/perl5/site_perl/5.16.2/x86_64-linux-thread-multi
/usr/lib/perl5/site_perl/5.16.2
/usr/lib/perl5/vendor_perl/5.16.2/x86_64-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.16.2
/usr/lib/perl5/5.16.2/x86_64-linux-thread-multi /usr/lib/perl5/5.16.2
/usr/lib/perl5/site_perl/5.16.2/x86_64-linux-thread-multi
/usr/lib/perl5/site_perl/5.16.2 /usr/lib/perl5/site_perl .) at
./OracleScript.pl line 4. BEGIN failed--compilation aborted at
./OracleScript.pl line 4.

I interpret this to mean that the Module is not installed. So, I tried to install it with the following command:

/usr/bin/perl -MCPAN -e'install Text::CSV_pm'

I get this error:

Database was generated on Mon, 06 Oct 2014 10:41:02 GMT Warning:
Cannot install Text::CSV_pm, don't know what it is. Try the command

    i /Text::CSV_pm/

to find objects with matching identifiers.

Can anybody shed some light on my issues, and how to remedy this?

Miller
  • 34,962
  • 4
  • 39
  • 60
NerdyBird
  • 109
  • 1
  • 5
  • 11

2 Answers2

10

Given that you're using the system Perl (and, from a comment, it seems you have root) then the easiest approach is probably to install the package that is pre-built for your Linux distribution.

For a Debian/Ubuntu-based system:

$ sudo apt-get install libtext-csv-perl

For a RedHat/Centos/Fedora-based system:

$ sudo yum install perl-Text-CSV
Dave Cross
  • 68,119
  • 3
  • 51
  • 97
7

If you are installing a module with CPAN, the syntax is

perl -MCPAN -e'install Module::Name'

No extension needed

So you need

perl -MCPAN -e'install Text::CSV'

Otherwise CPAN will search for a module called Text::CSV_pm, which (obviously) doesn't exist.

You can also use cpan in interactive module, which is a little more friendly:

perl -MCPAN -e shell

It's best to run it as root (i.e. sudo perl -MCPAN -e shell) if you're trying to update your system perl, or set up cpan so that it writes to directories that you own (e.g. your home directory).

i alarmed alien
  • 9,412
  • 3
  • 27
  • 40
  • This should be preferred in windows only. I would NOT recommend installing from CPAN in linux. Use distribution repositories instead. Versions of libraries from CPAN may not be entirely compatible with version of Perl and libraries in linux repository. To stay consistent everything should be installed from native linux repository. Whenever possible. This way all dependent modules are guaranteed to be working well together. – oᴉɹǝɥɔ Apr 10 '15 at 14:24
  • I would not use this method to install Perl modules (there are better technologies available which give you more control over the process), but it answers the specific question that the user asked. – i alarmed alien Mar 06 '20 at 22:47