eugene
12-07-2003, 12:41 AM
I keep reading messages from people concerning "missing" perl modules. I assume that the fact that these messages are posted implies that you have little to no experience with perl.
In perl, one imports modules/packages/functions via the use, do EXPR, or require.
If the module you need is not already installed server-wide, you have several options to use it yourself.
The easiest way is simply to put the module in the same directory as the perl script. I have verified that the HostPC DirectAdmin install will read from the local directory when mporting modules.
Another way consists of modifying the @INC array (the array the system searches for library files). If you install your modules elsewhere, you may modify the perl script like so:
push @INC, "modulepath";
Note: The . directory is not in the import path if taint checks are enabled, either via -T or by -t. Joe has not enabled taint checking systemwide, so, if you are having problems, you may need to check that the first line of your perl script does not read #!/usr/bin/perl -t or #!/usr/bin/perl -T. If the -t or -T is there, try removing it. :rolleyes: Taint checking is a VERY good idea, and use of the following option will allow you to keep the code taint-checked and use your own modules.
However, if you wish to modify this at runtime, you should use the use lib pragma to get the machine-dependent library properly loaded also:
use lib '/myPath/libDir/';
use myModule;
A third option, (not recommended by Eugene) is to insert hooks directly into the file inclusion system by putting Perl code directly into @INC. Those hooks may be subroutine references, array references or blessed objects.
local perlguru/perlgrammer
-Eugene
P.S. A simple description of Taint Checks (http://gunther.web66.com/FAQS/taintmode.html).
In perl, one imports modules/packages/functions via the use, do EXPR, or require.
If the module you need is not already installed server-wide, you have several options to use it yourself.
The easiest way is simply to put the module in the same directory as the perl script. I have verified that the HostPC DirectAdmin install will read from the local directory when mporting modules.
Another way consists of modifying the @INC array (the array the system searches for library files). If you install your modules elsewhere, you may modify the perl script like so:
push @INC, "modulepath";
Note: The . directory is not in the import path if taint checks are enabled, either via -T or by -t. Joe has not enabled taint checking systemwide, so, if you are having problems, you may need to check that the first line of your perl script does not read #!/usr/bin/perl -t or #!/usr/bin/perl -T. If the -t or -T is there, try removing it. :rolleyes: Taint checking is a VERY good idea, and use of the following option will allow you to keep the code taint-checked and use your own modules.
However, if you wish to modify this at runtime, you should use the use lib pragma to get the machine-dependent library properly loaded also:
use lib '/myPath/libDir/';
use myModule;
A third option, (not recommended by Eugene) is to insert hooks directly into the file inclusion system by putting Perl code directly into @INC. Those hooks may be subroutine references, array references or blessed objects.
local perlguru/perlgrammer
-Eugene
P.S. A simple description of Taint Checks (http://gunther.web66.com/FAQS/taintmode.html).