2019-07-12
@INC Perl- Can't locate Class/CSV.pm in @INC
stackoverflow
Question

I am currently trying to create/generate a CSV file using one of three classes:

use Class::CSV;
use Text::CSV;
use Text::CSV_XS;

Though when I try and run it, to check my code I come up with the same error message:

Can't locate Class/CSV.pm in @INC (@INC contains: C:/Per/site/lib C:/Perl/lib .) at C:\Users\<DIRECTORY> - <DIRECTORY>.file.pl line1

I have tried searching for the files though I haven't had any luck. Has anyone else come up against this problem? I have looking in the Directory and the CSV.pm file does exists.

Answer
1

Assuming that Class::CSV is installed on your system, your library search path is incomplete. (Your error message lists C:/Per/site/lib as a search lib, which looks like a typo for C:/Perl/site/lib, which you might want to look into.)

You need to locate the correct CSV.pm file where the library is located. For example, if it's found in:

C:/Perl/lib/foo/Class/CSV.pm

Then you have one of the following options.

  1. Modify the environment for Perl or the invocation so that this is set (assuming my Windows skill haven't expired completely, someone feel free to edit and correct if I get the syntax wrong):

    PERL5LIB=%PERL5LIB%;C:/Perl/lib/foo
    
  2. You can use the -I option to perl to add the path:

    perl -IC:/Perl/lib/foo my-app.pl
    
  3. You can use the use lib command in the program itself to add the search path:

    use lib 'C:/Perl/lib/foo';
    use Class::CSV;
    # etc.
    
@INC Perl- Can't locate Class/CSV.pm in @INC
See more ...