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

Hi Monks, I have been given a perl module to use but don't have the correct permissions to install in on my server. I have been told that one way around this is to create a folder in my home directory called 'Plug-in' and then put the file into it.

How can i then use this in my perl script? How can I tell perl to look for the module in this location?

I have tried the following:

# module is in ~/Plug-ins/Find.pm use Plug-ins::Find;

But I get this error:

Can't locate Plug.pm in @INC (@INC contains: /biol/programs/perl580/li +b/5.8.0/i686-linux /biol/programs/perl580/lib/5.8.0 /biol/programs/pe +rl580/lib/site_perl/5.8.0/i686-linux /biol/programs/perl580/lib/site_ +perl/5.8.0 /biol/programs/perl580/lib/site_perl .) at get_them.pl lin +e 5. BEGIN failed--compilation aborted at get_them.pl line 5.
Kind regards
K

Replies are listed 'Best First'.
Re: using perl plug-ins
by tinita (Parson) on Feb 19, 2006 at 13:41 UTC
    try:
    use lib "$ENV{HOME}/Plug-ins"; use Find;
    i guess the package name of the module is 'Find' and not 'Plug-ins::Find'. dashes are not allowed in package names, at least not unquoted.
Re: using perl plug-ins
by borisz (Canon) on Feb 19, 2006 at 14:10 UTC
    Or set your Environment var PERL5LIB to the plugin directory.
    export PERL5LIB=$HOME/plug-ins use Find;
    And notice, that a dash is not a good choice as part of a directoryname. Even if it does not mater for your example:
    use Plug-ins::Find; # is seen by perl as use Plug '-ins::Find';
    Boris
Re: using perl plug-ins
by brian_d_foy (Abbot) on Feb 19, 2006 at 18:57 UTC

    You can't use a hyphen as part of a package name. You have a package named "Plug-in.pm"; but it's looking for "Plug.pm", after which it will substract the result of &in::Find.

    Beside that, you may want to see the answers to " How do I keep my own module/library directory?" and "How do I add a directory to my include path (@INC) at runtime?" in perlfaq8.

    Good luck :)

    --
    brian d foy <brian@stonehenge.com>
    Subscribe to The Perl Review
Re: using perl plug-ins
by arcnon (Monk) on Feb 19, 2006 at 15:06 UTC
    think of it like so..... your directory structure
    home ........your home dir test.pl ........the script your running Plug-Ins ........the folder you made Find.pm ........the module you added More ........and another folder More.pm....and another module
    in test.pl
    use Plug-Ins::Find; use Plug-Ins::More::More;
    If the module is not installed think of 'use' as the path to where the module you want to use is located.. This is useful only in a descending folder structure.

      If you do something like this, remember that Plug-Ins is not a valid package name. Also, remember that the file that you use has to think that it is defining a package called "Plugin::Find", not just "Find". The file will be required, but the package will not be import()ed, unless the OP edits his modules to use the new qualified package name.

      This solution also assumes that "." (the CWD) is in the OP @INC, and that the OP will only ever run it from that directory.

      The best solution is just to use lib, though, with a full qualified path:

      use lib '/some/dir/Plug-Ins/'; use Find;