XML::RSS
michael at diaspora.gen.nz
michael at diaspora.gen.nz
Fri Apr 25 19:22:58 CDT 2003
>use lib "/projects/spectre/lib";
></quote>
>I presume that this would be put into a Begin sub:
>Begin (
> use lib "/projects/spectre/lib";
>)
Sort of. "perldoc -u lib" reveals:
The parameters to C<use lib> are added to the start of the perl search
path. Saying
use lib LIST;
is I<almost> the same as saying
BEGIN { unshift(@INC, LIST) }
"use" is processed at compile time, rather than at run time; obviously,
the compiler needs to know what extra semantics you're importing into
your namespace, so it can generate the appropriate code.
In your case, you want to alter @INC to include your cgi-bin directory,
so you can include your own copy of XML::RSS.[0] So you want to put:
use lib "path/to/your/cgi-bin";
at the top of your script, which is *almost* like saying[1]:
BEGIN { unshift(@INC, "path/to/your/cgi-bin") }
Ewen's suggesting that if you want to use lots of local modules, you
reduce the mess by creating "path/to/your/cgi-bin/local-libs", and put
the modules in there; the "use lib" statement changes in a corresponding
manner.
-- michael.
[0] However, if you want to then write "use XML::RSS", you'll need to
put the RSS.pm file in path/to/your/cgi-bin/XML/, to preserve the
convention that :: means "a directory". This is documented under
"perldoc -f require"; "::" gets replaced with "/".
[1] Which in turn, if you're unfamiliar with unshift (perldoc -f
unshift), means something like:
BEGIN { @INC = ("path/to/your/cgi-bin", @INC) }
More information about the Wellington-pm
mailing list