How can I find out where a Perl module is installed?

后端 未结 9 645
小蘑菇
小蘑菇 2021-01-30 10:30

How do get the path of a installed Perl module by name, e.g. Time::HiRes?

I want this just because I have to run my perl script on different nodes of a SGE

相关标签:
9条回答
  • 2021-01-30 11:09

    In OSX you can use:

    perl -e 'print join("\n",@INC)'

    The result should be the location of your lib.

    Then add this code in your Perl code:

    use lib '/your/folder/location/to/lib';
    
    0 讨论(0)
  • 2021-01-30 11:10

    If need to find which modules are actually used by your script you can use perl debuggers M command:

    [ivan@server ~]$ perl -d your_script.pl
    ...
    
    Debugged program terminated.  Use q to quit or R to restart,
      use o inhibit_exit to avoid stopping after program termination,
      h q, h R or h o to get additional info.
    
    DB M
    'AutoLoader.pm' => '5.60 from /usr/lib/perl5/5.8.8/AutoLoader.pm'
    'Carp.pm' => '1.04 from /usr/lib/perl5/5.8.8/Carp.pm'
    ...
    

    This will help in case when you have modules with same names but in different folder.

    0 讨论(0)
  • 2021-01-30 11:11

    perl -MTime::HiRes -e 'print $INC{"Time/HiRes.pm"}' or perldoc -l Time::HiRes

    0 讨论(0)
提交回复
热议问题