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

前端 未结 24 2647
情深已故
情深已故 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:46

    A couple of people mentioned the cpan utility, but it's more than just starting a shell. Just give it the modules that you want to install and let it do it's work.

    $prompt> cpan Foo::Bar
    

    If you don't give it any arguments it starts the CPAN.pm shell. This works on Unix, Mac, and should be just fine on Windows (especially Strawberry Perl).

    There are several other things that you can do with the cpan tool as well. Here's a summary of the current features (which might be newer than the one that comes with CPAN.pm and perl):

    -a
    Creates the CPAN.pm autobundle with CPAN::Shell->autobundle.
    
    -A module [ module ... ]
    Shows the primary maintainers for the specified modules
    
    -C module [ module ... ]
    Show the Changes files for the specified modules
    
    -D module [ module ... ]
    Show the module details. This prints one line for each out-of-date module (meaning,
    modules locally installed but have newer versions on CPAN). Each line has three columns:
    module name, local version, and CPAN version.
    
    -L author [ author ... ]
    List the modules by the specified authors.
    
    -h
    Prints a help message.
    
    -O
    Show the out-of-date modules.
    
    -r
    Recompiles dynamically loaded modules with CPAN::Shell->recompile.
    
    -v
    Print the script version and CPAN.pm version.
    

提交回复
热议问题