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

Hi monks, I am new to Perl and this community and still learning the amazing language. However, I have run into a roadblock while using CPAN modules. Every CPAN module that I install gets installed properly, but when I use it in my code, the compiler throws an error "Can't locate <module_name.pm in @INC", when @INC contains the path where the module has beebn installed. For example :

1. I installed Term::ANSIColor through CPAN

2. Running the UNIX command "sudo find / -name ANSIColor.pm -print" gives me the following output :

/home/amit/.cpan/build/Term-ANSIColor-3.02-qAhFw6/blib/lib/Term/ANSICo +lor.pm /home/amit/.cpan/build/Term-ANSIColor-3.02-qAhFw6/ANSIColor.pm /usr/local/share/perl/5.10.1/Term/ANSIColor.pm /usr/share/perl/5.10.1/Term/ANSIColor.pm

3. Executing the code

#!/usr/bin/perl use warnings; BEGIN { push @INC,"/usr/share/perl/5.10.1"; } use TERM::ANSIColor; print color("red"), "hello world\n", color("reset");

gives me the following output

Can't locate TERM/ANSIColor.pm in @INC (@INC contains: /etc/perl /usr +/local/lib/perl/5.10.1 /usr/local/share/perl/5.10.1 /usr/lib/perl5 /u +sr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib +/site_perl . /usr/share/perl/5.10.1) at ./ansicol.plx line 8. BEGIN failed--compilation aborted at ./ansicol.plx line 8.

So, the directory which contains the .pm file is already in @INC still I get the error. Please help me out as this is quite frustrating and I have not been able to use any modules because of this error. Thanks!

Replies are listed 'Best First'.
Re: Can't find <module> in @INC error
by choroba (Cardinal) on Jun 06, 2012 at 01:23 UTC
    The name of the module is Term::ANSIColor, not TERM::ANSIColor. Perl is case sensitive even on systems that are not.

      Thanks choroba. Just after I posted the questioned I figured that out by going to the directory where the module was installed. However, thanks for the quick reply. :) Jeez, I started off with a blooper on Perlmonks ... :|

        Any question that contains enough information for the first response to comprehensively answer, is a good one.
        perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
Re: Can't find <module> in @INC error
by toolic (Bishop) on Jun 06, 2012 at 13:55 UTC
    I installed Term::ANSIColor through CPAN
    Since Term::ANSIColor is a Core module, you should not have had to install it:
    corelist Term::ANSIColor Term::ANSIColor was first released with perl v5.6.0

      Thanks toolic. I was hitherto unaware of that. Forgive my ignorance as I am still learning the language.