How to add path to Perl lib?
3 answers
Hi
I got an error like this: Can't locate bcc.pm in @INC. How can I add a path to the default @INC for Perl in BF.
Thanks
Jirong
Hi Jirong,
You might try setting the environment variable PERL5LIB or PERLLIB with the directory of your module. Another option would be to specify the -I option when invoking perl (ex. perl -I/module/dir script.pl) .
bju
Hi
I got an error like this: Can't locate bcc.pm in @INC. How can I add a path to the default @INC for Perl in BF.
Thanks
Jirong
There are a few methods for doing this.
1) Add a "require" or "use" pragma providing the full path to the module
require "\usr\etc\modules\bbc"
2) Add the path to @INC using push or unshift. One adds to the end of the list and the other to the front. Which is which I will leave as an exercise to the reader ;-)
unshift @INC, "\some\path"
All of the above.
Also, you can add a -I to your perl magic line in the script (that's a capital i in case your font makes it look like a lowercase L like mine does)
for instance:
Though I prefer the env var route myself as if you're going to include a directory for one script, it's likely that you'll include it for several.
Also, you can add a -I to your perl magic line in the script (that's a capital i in case your font makes it look like a lowercase L like mine does)
for instance:
#!/usr/bin/perl -I/home/rhaig/perllib
Though I prefer the env var route myself as if you're going to include a directory for one script, it's likely that you'll include it for several.