How do I install Perl modules on machines without an Internet connection?

旧城冷巷雨未停 提交于 2019-11-27 14:22:57

The usual way to solve "I want to install stuff from CPAN but without network" problems is to use a minicpan as David Dorward wrote in his answer. But since you're going one step further, saying that you'd rather not do any real installation on the client (target) machines at all, and that you want to use precompiled modules if possible, I urge you to check out PAR and specifically PAR::Repository (server) and PAR::Repository::Client.

Since this approach needs some research before you're up to speed, I wouldn't suggest it for "I just need Foo.pm" like problems. Once you're talking about a handful of dependencies and at least a handful of clients, then it becomes a more appropriate solution.

For an outline of how it works, check out the slides of my talk at YAPC::EU 2008. It also hints at solutions to the bootstrapping problem of making the PAR::Repository::Client module available on the clients (hint: PAR can generate self-contained executables).

You can create a MiniCPAN that has just the latest versions of everything from CPAN. You can insert additional, non-public modules into it with CPAN::Mini::Inject. If you need to greater control over versions (i.e. not choosing the latest versions), you might want to create a DPAN.

With any of these solutions, you can configure your CPAN client to pull from your local source. That could be a directory you know ahead of time or something that you figure out dynamically, like a CD or a thumb-drive. It's just a matter of setting up the configuration correctly.

You might be able to get away with creating operating-system packages for most of your work, but that still means you have to compile them at least the first time.

1) How/Where to get specific versions of Perl modules, e.g. CGI.pm etc

http://search.cpan.org/

If you don't want the latest version, you can get an earlier version by following the link in the breadcrumbs.

http://img.skitch.com/20091209-bu7kt3bj65374k7iijfnhrue2y.png

2) How to install these Perl modules. Is it a case of just placing them in a directory somewhere, e.g. a library path and making sure that this directory path is in the @INC library path environmental variable, if it is not already?

That sometimes work, but you really should go through the perl Makefile.PL && make && make test && make install process.

Doing this would require that you manually chase all the dependencies though. You would probably be better off with something like minicpan.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!