Akhenaton has asked for the wisdom of the Perl Monks concerning the following question:

Seeking monkly help... I have a question about using a method from CPAN. If I want to avoid messing with a build doc for a production server, could I just insert use lib "/some/path/to/dir/of/method/here"; use some::method; ? Thanks for any advice I have a long way to go to even consider myself a perl newb... :)

Replies are listed 'Best First'.
Re: using methods/modules ?
by lima1 (Curate) on Jun 22, 2006 at 18:57 UTC
    yeah, but it would look like
    use lib '/some/path/to/local/modules'; # /some/path/to/local/modules/Some/Module.pm use Some::Module;
    you can install perl modules in that directory with perl Makefile.PL PREFIX="/some/path/to/local/modules/"
Re: using methods/modules ?
by Joost (Canon) on Jun 22, 2006 at 19:02 UTC
    I assume that by "method" you mean "module". In theory, you can "use lib", but in general, you shouldn't assume that anything will work without installing (or at least building) the module first.

    Installing modules isn't hard: most perl modules use the same sequence of commands for building / installing:

    # perl Makefile.PL # make # make test # make install
    As long as the modules don't include C/XS code, all you need to install them is a standard make command.

    Some newer modules use Module::Build instead. Theoretically, you'll only need perl to build those (again, unless you need to compile C/XS code, in which case you'd need a working C compiler).

    Personally, I tend to just use either the CPANPLUS or CPAN module to install stuff. It generally is a lot less hassle than trying to subvert the installation process, unless you know what you're doing. In other words, since you're new to perl, please don't mess about with this, and install the modules like they expect to be installed. You'll save yourself a lot of trouble.

    See also A Guide to Installing Modules.

      Thank you lots of good stuff and I agree, I will just install them the way they are meant to be. Thanks.
Re: using methods/modules ?
by shmem (Chancellor) on Jun 22, 2006 at 18:58 UTC
    You can use lib "/path/to/my/custom/modules"; and use the modules stored there. The path in this statement will be prepended to perl's search path. See perlmodlib.

    You can also set the environment variable PERL5LIB to some path. Has the same effect (but this path will be second, if you do use lib

    _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                  /\_¯/(q    /
    ----------------------------  \__(m.====·.(_("always off the crowd"))."·
    ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
      Thank you both. I am obvisouly new, and someone pointed out I could just install the mods, I was hoping to avoid this and probably can, but installing the mods on the servers will work and its a simple build doc update here for said server. learn something new every day lol - perl Makefile.PL make make test make install I am really begining to see the importance of this site. :)