It's all about the answers!

Ask a question

How to add path to Perl lib?


Jirong Hu (1.5k9295258) | asked Aug 19 '10, 5:01 p.m.
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

3 answers



permanent link
Brent Ulbricht (2.5k11) | answered Aug 19 '10, 5:14 p.m.
JAZZ DEVELOPER
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

permanent link
Bryan Miller - Integration Developer (4493531) | answered Nov 30 '10, 3:09 p.m.
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"

permanent link
Robert haig (1.0k16) | answered Dec 08 '10, 1:43 p.m.
FORUM MODERATOR / JAZZ DEVELOPER
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:
#!/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.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.