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

后端 未结 9 647
小蘑菇
小蘑菇 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:04

    Note: This solution proposes use of a (self-authored) utility that you must download. While it offers what I believe to be helpful features, installing a third-party solution first is not an option for everyone.


    I've created whichpm, a cross-platform CLI (Linux, macOS, Window) that locates installed Perl modules by module (package) name, and optionally reports information about them, including detection of accidental duplicates.

    Examples

    # Locate the Data::Dumper module.
    $ whichpm Data::Dumper
    /usr/lib/perl/5.18/Data/Dumper.pm
    
    # Locate the Data::Dumper module, and also print
    # version information and core-module status.
    $ whichpm -v Data::Dumper
    Data::Dumper    2.145   core>=5.005 /usr/lib/perl/5.18/Data/Dumper.pm
    
    # Locate the Data::Dumper module and open it in your system's default text
    # editor.
    $ whichpm -e Data::Dumper
    
    # Look for accidental duplicates of the Foo::Bar module.
    # Normally, only 1 path should be returned.
    $ whichpm -a Foo::Bar
    /usr/lib/perl/5.18/Foo/Bar.pm
    ./Foo/Bar.pm
    
    # Print the paths of all installed modules.
    $ whichpm -a
    

    Installation

    Prerequisites: Linux, macOS, or Windows, with Perl v5.4.50 or higher installed.

    Installation from the npm registry

    With Node.js or io.js installed, install the package as follows:

    [sudo] npm install whichpm -g
    

    Manual installation (macOS and Linux)

    • Download the CLI as whichpm.
    • Make it executable with chmod +x whichpm.
    • Move it or symlink it to a folder in your $PATH, such as /usr/local/bin (OSX) or /usr/bin (Linux).

提交回复
热议问题