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!


In reply to Can't find <module> in @INC error by maanu2k

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.