What modules are distributed with Perl?

前端 未结 8 1513
误落风尘
误落风尘 2021-02-13 20:00

How do I know what modules are distributed with Perl?

My first guess is that the core modules listed here are always included, though I cannot find this stated explicitl

8条回答
  •  感情败类
    2021-02-13 20:28

    The correct straight forward answers have already been given, but I think you've asked the wrong question. You're probably trying to develop using only core modules. Why? You're probably doing this because you don't want to deal with dependencies. Why? Because they can be a pain in the ass. But developing Perl without CPAN is missing half the power. You're crippling yourself. It's worth it.

    Update: Now that I know more about what you're trying to do, I can answer the right question. First is "how do I install a module when I don't have root?" The simple answer is this:

    perl Makefile.PL PREFIX=/some/path LIB=/some/path/lib
    ...and all the rest as normal...
    

    for MakeMaker based modules (LIB is used to control the otherwise inexact nature of PREFIX. INSTALL_BASE is preferred, but it is not backwards compatible).

    and this for Module::Build

    perl Build.PL --install_base=/some/path
    

    and then modules will wind up in /some/path/lib and you can set the PERL5LIB environment variable or use lib qw(/some/path/lib) in your code.

    This means you can stick dependent modules straight into your software distribution and ship them. Works fine for pure-Perl modules. For stuff that requires a compiler, look at PAR as others have suggested to be able to ship compiled executables.

    Alternatively, you can distribute your stuff as a CPAN module, complete with dependencies spelled out, and let a CPAN client resolve them. You can even use Module::AutoInstall to perform this process outside of a CPAN client.

    So you see, you're not restricted to using just core modules when shipping a Perl app.

提交回复
热议问题