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

I have failed twice to get this to work. I find some niche module on CPAN, which is just a single .pm file containing perl code. Everything looks good, functions are exported, etc. The two packages are initialized thusly:

use Beep;

and, in another attempt in seperate file:

use Local:TeeOutput;

The common point here is that I don't know how to install these in a nice place, so have been testing them out by putting e.g., Beep.pm in the pwd and TeeOutput.pm in ./Local/ . This was what everything I found online told me would work. It does not. I get the following errors when trying to access functions clearly exported within these files:

Undefined subroutine &main::beep called at ./beep.pl line 5.

Previously I had figured out how to make my perl program find the /Local/ directory I had created, and now that I'm writing this I can't repeat that, so my new problem for that case is that @INC seems to be ignoring it's own contents?

Can't locate TeeOutput.pm in @INC (@INC contains: /(my pwd)/ ./ /etc/perl /usr/local/lib/perl/5.10.0 /usr/local/share/perl/5.10.0 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10 /usr/local/lib/site_perl .) at ./test3.pl line 4. BEGIN failed--compilation aborted at ./test3.pl line 4.

I can post more info, but I have a feeling I'm just doing something very obviously dumb to anyone who knows what's going on.

Thanks for your wonderful site!

  • Comment on Installing perl-only .pm modules locally??

Replies are listed 'Best First'.
Re: Installing perl-only .pm modules locally??
by John M. Dlugosz (Monsignor) on May 12, 2009 at 19:33 UTC
    Check out the use lib pragma, to tell it where you put your private stash.

    Or, use the current directory. Note that the nested namespaces imply subdirectories of that name.

    —John

Re: Installing perl-only .pm modules locally?? (cpan custom lib)
by ikegami (Patriarch) on May 12, 2009 at 21:21 UTC
    In my login script, I have
    export PERL5LIB=~/lib/perl5
    To install a module, Pure Perl or otherwise, I do
    perl Makefile.PL PREFIX=~ LIB=~/lib/perl5 make make test make install

    I actually use the cpan tool, which allows you to specify command line parameters for Makefile.PL. Do so (once) using:

    o conf makepl_arg PREFIX=~ LIB=~/lib/perl5 o conf commit

    Caveat: PERL5LIB isn't honoured when taint checking is enabled. Add the following to such scripts to make them work:

    use lib '/home/ikegami/lib/perl5';
Re: Installing perl-only .pm modules locally??
by toolic (Bishop) on May 12, 2009 at 20:30 UTC
Re: Installing perl-only .pm modules locally??
by John M. Dlugosz (Monsignor) on May 12, 2009 at 19:35 UTC
    P.S. Welcome to the monastery.