7

I need to retrieve the path where the perl libraries Statistics and Distributions are located. The path is necessary to run the script. I'm on a computer cluster. Can anyone help me?

Thanks

NewUsr_stat
  • 2,351
  • 5
  • 28
  • 38
  • We're here to help. Please give us your username and password and the name or IP address of a machine on your cluster. One of us will be happy to poke around and see where the libraries can be found. [Edit: smiley face] – mob Sep 07 '12 at 15:08
  • yes, of course...just getting fired tomorrow! – NewUsr_stat Sep 07 '12 at 15:11
  • Your question (as of know) is too vague. I understand it as: a script of yours tries to load some modules, and fails. Please edit the question to add the error line "can't locate Statistics/Distributions.pm in @INC" (taken from your comment below). – Ben Deutsch Sep 07 '12 at 19:37

5 Answers5

10

This answer assumes that the module is in fact installed, but not in a place that perl is looking for.

Generally, the Perl module Statistics::Distributions will be contained in a file called Statistics/Distributions.pm. On Linux and similar systems, one can search for these files quickly with the locate command:

locate Statistics/Distributions.pm

If it is installed, locate will spit out a line similar to

/opt/my_perl/lib/Statistics/Distributions.pm

You can then instruct the perl interpreter to look in this path, too, in various ways. One is to define the environment variable PERL5LIB, i.e. from bash:

prompt> PERL5LIB=/opt/my_perl/lib/ ./myscript.pl

Or you can use the perl -I switch:

prompt> perl -I/opt/my_perl/lib/ ./myscript.pl

Or you can modify the script to use lib; there is more than one way to do it ;-)

Ben Deutsch
  • 688
  • 1
  • 5
  • 11
5

perldoc -m Your::Module - displays source of module

perldoc -l Your::Module - display path to library if it's installed and found in PERL5LIB, -I, @INC, etc.

4

If you mean you need the path of a module you're using in a program, that's stored in %INC:

$ perl -MLWP::Simple -le 'print $INC{"LWP/Simple.pm"}'
/usr/share/perl5/LWP/Simple.pm
zigdon
  • 14,573
  • 6
  • 35
  • 54
  • Since the script was not written by me I'm reporting the comment reported:Dependency: library Statistics::Distributions (please modify the first line of the script to set the path to the library location – NewUsr_stat Sep 07 '12 at 15:01
  • @Eleonora Lusito, To your question, add the **exact** error message and demonstrate what triggers its appearance. – ikegami Sep 07 '12 at 15:05
  • ok, trying to run the script, the error appearing is: can't locate Statistics/Distributions.pm in @INC – NewUsr_stat Sep 07 '12 at 15:08
  • sorry memowe, I don' t understand your question. – NewUsr_stat Sep 07 '12 at 15:37
  • 1
    Sounds like you just need to run `cpan Statistics::Distributions` to install the module. See also http://stackoverflow.com/questions/65865 – Oktalist Sep 07 '12 at 16:06
  • Use `@ikegami` when you reply to ikegami to notify him of your comment. Otherwise, only the person who wrote the answer or question to which you are replying gets notified. – ikegami Sep 07 '12 at 16:09
1

"Can't locate XXX in @INC" usually indicates the module isn't installed. Have you installed Statistics::Distributions?

cpan Statistics::Distributions
ikegami
  • 367,544
  • 15
  • 269
  • 518
0

I had the same trouble and it can be fixed both ways:

1) by running the command

perl -I/blabla/folder_your_module_is_installed/blib/lib/ ./script.pl

for dummies like me, it is important to note that the end of the path is lib/, not lib/Other_folder/. Because there are more folders after it.

2) inside the script you can write:

use lib 'blabla/folder_your_module_is_installed/blib/lib/';

save and run perl scripit.pl

Adam Katz
  • 14,455
  • 5
  • 68
  • 83