[pm-h] How to update @INC from within a script?
Kristofer Hoch
kristoferhoch at yahoo.com
Tue Dec 6 16:57:35 PST 2005
Jay,
That BEGIN trick is commonly used to create a singleton design pattern. It is very misleading, and you really have read the Perl documentation to understand what to do and when.
Glad to help,
Kristofer
Jay Vogt <jvogt at houston.oilfield.slb.com> wrote: All,
Thanks for the suggestions. Error came from a mistaken belief
that the BEGIN statement would be executed first regardless of
its position in the script. All worked fine once I move the BEGIN
block to the very beginning of the script as Kristofer indicated.
Not sure where I go the notion that BEGIN statement did not have
to be at the start of the script.
Wade - the reason for the perl with non-existent directories for @INC
is because it is sent to clients who can install in any directory they
want. I don't suppose that @INC can point to directories with
relative paths or variables in them.
Thanks,
Jay Vogt
Kristofer Hoch wrote:
Jay,
Try this at the very top of your script
#!/path/to/perl
BEGIN { push(@INC, '/path/to/DBI/directory'); }
Jay Vogt <jvogt at houston.oilfield.slb.com> wrote: All,
When I point to a particular Perl executable the @INC array
points to non-existent directories. I've tried to update @INC
within my script to point to the directories which do contain DBI
using the unshift technique found in the O'Reilly books (whether
in a BEGIN statement or elsewhere in the script before
I execute "use DBI"). Printing the contents of @INC (by commenting
out "use DBI") shows that the array is modified, but when including
"use DBI" I get an error that DBI.pm is not in @INC and it lists
only those non-existent directories.
The "use DBI" statement seems to be processed a t script compilation
time and not following the BEGIN block. The only way my script
sees the DBI module is if I set the environment variable PERL5LIB
in an xterm before running the script. Setting $ENV{PERL5LIB}
within my script does not work.
Any suggestions on how to modify @INC from within a script
so that it is actually read?
Thanks,
Jay Vogt
_______________________________________________
Houston mailing list
Houston at pm.org
http://mail.pm.org/mailman/listinfo/houston
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GIT d s+:++ a C++ UL++ US+ P+++ L++
W+++ w PS PE t++ b+ G e r+++ z++++
------END GEEK CODE BLOCK------
---------------------------------
Yahoo! DSL Something to write home about. Just $16.99/mo. or less
---------------------------------
_______________________________________________
Houston mailing list
Houston at pm.org
http://mail.pm.org/mailman/listinfo/houston
--
___________________________________________________________________________________________________
Jay Vogt Schlumberger Information Solutions GeoFrame Portfolio Product Champion 713 513 2335 Houston, TX
_______________________________________________
Houston mailing list
Houston at pm.org
http://mail.pm.org/mailman/listinfo/houston
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GIT d s+:++ a C++ UL++ US+ P+++ L++
W+++ w PS PE t++ b+ G e r+++ z++++
------END GEEK CODE BLOCK------
---------------------------------
Yahoo! Personals
Single? There's someone we'd like you to meet.
Lots of someones, actually. Yahoo! Personals
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/mailman/private/houston/attachments/20051207/f289cd2d/attachment.html
More information about the Houston
mailing list