What's the easiest way to install a missing Perl module?

前端 未结 24 2632
情深已故
情深已故 2020-11-21 05:28

I get this error:

Can\'t locate Foo.pm in @INC

Is there an easier way to install it than downloading, untarring, making, etc?

相关标签:
24条回答
  • 2020-11-21 05:54

    On Fedora Linux or Enterprise Linux, yum also tracks perl library dependencies. So, if the perl module is available, and some rpm package exports that dependency, it will install the right package for you.

    yum install 'perl(Chocolate::Belgian)'
    

    (most likely perl-Chocolate-Belgian package, or even ChocolateFactory package)

    0 讨论(0)
  • 2020-11-21 05:55

    2 ways that I know of :

    USING PPM :

    With Windows (ActivePerl) I've used ppm

    from the command line type ppm. At the ppm prompt ...

    ppm> install foo
    

    or

    ppm> search foo
    

    to get a list of foo modules available. Type help for all the commands

    USING CPAN :

    you can also use CPAN like this (*nix systems) :

    perl -MCPAN -e 'shell'
    

    gets you a prompt

    cpan>
    

    at the prompt ...

    cpan> install foo  (again to install the foo module)
    

    type h to get a list of commands for cpan

    0 讨论(0)
  • 2020-11-21 05:56

    On Windows with the ActiveState distribution of Perl, use the ppm command.

    0 讨论(0)
  • 2020-11-21 05:58

    On ubuntu most perl modules are already packaged, so installing is much faster than most other systems which have to compile.

    To install Foo::Bar at a commmand prompt for example usually you just do:

    sudo apt-get install libfoo-bar-perl
    

    Sadly not all modules follow that naming convention.

    0 讨论(0)
  • 2020-11-21 05:58

    Secure solution

    Many answers mention the use of the cpan utility (which uses CPAN.pm) without a word on security. By default, CPAN 2.27 and earlier configures urllist to use a http URL (namely, http://www.cpan.org/), which allows MITM attacks, thus is insecure. This is what is used to download the CHECKSUMS files, so that it needs to be changed to a secure URL (e.g. https://www.cpan.org/).

    So, after running cpan and accepting the default configuration, you need to modify the generated MyConfig.pm file (the full path is output) in the following way. Replace

    'urllist' => [q[http://www.cpan.org/]],
    

    by

    'urllist' => [q[https://www.cpan.org/]],
    

    Note: https is not sufficient; you also need a web site you can trust. So, be careful if you want to choose some arbitrary mirror.

    Then you can use cpan in the usual way.

    My bug report on rt.cpan.org about the insecure URL.

    0 讨论(0)
  • 2020-11-21 05:58

    Simply executing cpan Foo::Bar on shell would serve the purpose.

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