For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > October 2006 > Where to change @INC in perl









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Where to change @INC in perl
Narmadha Palanisamy

2006-10-04, 3:57 am


=0D
Hi,

I am newbie to the perl.=0D
I have installed DBI perl module in FreeBSD under this directory
/usr/local/lib/perl5/5.00503.
But FreeBSD already contains perl5 under /usr/local/lib/perl5/5.8.7.


# Perl -V
Built under freebsd
Compiled at Oct 12 2005 01:26:55
@INC:
/usr/local/lib/perl5/site_perl/5.8.7/mach
/usr/local/lib/perl5/site_perl/5.8.7
/usr/local/lib/perl5/site_perl
/usr/local/lib/perl5/5.8.7/BSDPAN
/usr/local/lib/perl5/5.8.7/mach
/usr/local/lib/perl5/5.8.7


I want include libraries from /usr/local/lib/perl5/5.00503 also.
But this DBI libraries does not include in @INC.

I want to change manually. Can anyone tell me where do I change this
@INC.

Thanks=0D
Narmadha


The information contained in this electronic message and any attachments to=
this message are intended for the exclusive use of the addressee(s) and=
may contain proprietary, confidential or privileged information. If you=
are not the intended recipient, you should not disseminate, distribute or=
copy this e-mail. Please notify the sender immediately and destroy all=
copies of this message and any attachments.=0D

WARNING: Computer viruses can be transmitted via email. The recipient=
should check this email and any attachments for the presence of viruses.=
The company accepts no liability for any damage caused by any virus=
transmitted by this email.
=0D
www.wipro.com
usenet@DavidFilmer.com

2006-10-04, 7:58 am

Narmadha Palanisamy wrote:
> Can anyone tell me where do I change this @INC.


The only way to change @INC is to recompile Perl (seriously).

But you can add something to @INC at runtime:

perldoc -q runtime

--
David Filmer (http://DavidFilmer.com)

Sami FANTAR

2006-10-04, 7:58 am

narmadha.palanisamy@wipro.com a écrit :
> Hi,
>
> I am newbie to the perl.
> I have installed DBI perl module in FreeBSD under this directory
> /usr/local/lib/perl5/5.00503.
> But FreeBSD already contains perl5 under /usr/local/lib/perl5/5.8.7.
>
>
> # Perl -V
> Built under freebsd
> Compiled at Oct 12 2005 01:26:55
> @INC:
> /usr/local/lib/perl5/site_perl/5.8.7/mach
> /usr/local/lib/perl5/site_perl/5.8.7
> /usr/local/lib/perl5/site_perl
> /usr/local/lib/perl5/5.8.7/BSDPAN
> /usr/local/lib/perl5/5.8.7/mach
> /usr/local/lib/perl5/5.8.7
>
>
> I want include libraries from /usr/local/lib/perl5/5.00503 also.
> But this DBI libraries does not include in @INC.
>
> I want to change manually. Can anyone tell me where do I change this
> @INC.
>
> Thanks
> Narmadha
>
>
> The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, y

ou should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.
>
> WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
>
> www.wipro.com
>
>

You can use

use lib 'the_path_to_your_local_module';
Narmadha Palanisamy

2006-10-04, 7:58 am


Hi Sami,

Thanks for the reply. I cannot change the *.cgi files. Is there anyway=
for setting the libraries manually.

Narmadha

-----Original Message-----
From: Sami FANTAR [mailto:sfantar@laposte.net]=0D
Sent: Wednesday, October 04, 2006 3:32 PM
To: beginners@perl.org
Subject: Re: Where to change @INC in perl

narmadha.palanisamy@wipro.com a =E9crit :
> Hi,
>
> I am newbie to the perl.
> I have installed DBI perl module in FreeBSD under this directory=0D
> /usr/local/lib/perl5/5.00503.
> But FreeBSD already contains perl5 under /usr/local/lib/perl5/5.8.7.
>
>
> # Perl -V
> Built under freebsd
> Compiled at Oct 12 2005 01:26:55
> @INC:
> /usr/local/lib/perl5/site_perl/5.8.7/mach
> /usr/local/lib/perl5/site_perl/5.8.7
> /usr/local/lib/perl5/site_perl
> /usr/local/lib/perl5/5.8.7/BSDPAN
> /usr/local/lib/perl5/5.8.7/mach
> /usr/local/lib/perl5/5.8.7
>
>
> I want include libraries from /usr/local/lib/perl5/5.00503 also.
> But this DBI libraries does not include in @INC.
>
> I want to change manually. Can anyone tell me where do I change this=0D
> @INC.
>
> Thanks
> Narmadha
>
>
> The information contained in this electronic message and any attachments=

to this message are intended for the exclusive use of the addressee(s) and=
may contain proprietary, confidential or privileged information. If you=
are not the intended recipient, you should not disseminate, distribute or=
copy this e-mail. Please notify the sender immediately and destroy all=
copies of this message and any attachments.
>
> WARNING: Computer viruses can be transmitted via email. The recipient=

should check this email and any attachments for the presence of viruses.=
The company accepts no liability for any damage caused by any virus=
transmitted by this email.
>
> www.wipro.com
>
> =0D

You can use

use lib 'the_path_to_your_local_module';

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org For additional=
commands, e-mail: beginners-help@perl.org <http://learn.perl.org/>=
<http://learn.perl.org/first-response>




The information contained in this electronic message and any attachments to=
this message are intended for the exclusive use of the addressee(s) and=
may contain proprietary, confidential or privileged information. If you=
are not the intended recipient, you should not disseminate, distribute or=
copy this e-mail. Please notify the sender immediately and destroy all=
copies of this message and any attachments.=0D

WARNING: Computer viruses can be transmitted via email. The recipient=
should check this email and any attachments for the presence of viruses.=
The company accepts no liability for any damage caused by any virus=
transmitted by this email.
=0D
www.wipro.com
Lee Goddard

2006-10-04, 7:58 am

> Is there anyway for setting the libraries manually.

See perldoc perlrun for how to include a directory in @INC, which is wher=
e perl looks for libraries:

-I*directory*
Directories specified by -I are prepended to the search path for=

modules (@INC), and also tells the C preprocessor where to searc=
h
for include files. The C preprocessor is invoked with -P; by
default it searches /usr/include and /usr/lib/perl.

hth
--=20
Lee Goddard

Independent Contractor, Software Development/Analysis
BBC Radio & Music Interactive
* Room 718 | Henry Wood Hs | Regents St | London W1 1AA | UK * 020 776 50=
849 * lee(at)server-sidesystems.ltd.uk

=20


http://www.bbc.co.uk/
This e-mail (and any attachments) is confidential and may contain persona=
l views which are not the views of the BBC unless specifically stated.
If you have received it in error, please delete it from your system.
Do not use, copy or disclose the information in any way nor act in relian=
ce on it and notify the sender immediately.
Please note that the BBC monitors e-mails sent or received.
Further communication will signify your consent to this.
=09
Klaus

2006-10-04, 7:58 am

Narmadha Palanisamy wrote:
> I cannot change the *.cgi files.


I keep my perl programs in *.pl files (for example "test.pl") and I run
them with "perl test.pl".

> Is there anyway for setting the libraries manually.


Found in perlfaq8.pod:
How do I add a directory to my include path (@INC) at runtime?

Here are the suggested ways of modifying your include path:

the PERLLIB environment variable
the PERL5LIB environment variable
the perl -Idir command line flag
the use lib pragma, as in
use lib "$ENV{HOME}/myown_perllib";

The latter is particularly useful because it knows about machine
dependent architectures. The lib.pm pragmatic module was first included
with the 5.002 release of Perl.

Rob Dixon

2006-10-04, 7:58 am

narmadha.palanisamy@wipro.com wrote:
>
> From: Sami FANTAR [mailto:sfantar@laposte.net]
>
> Thanks for the reply. I cannot change the *.cgi files. Is there anyway for
> setting the libraries manually.


Hi Narmadha

(Please bottom-post your answers and remove all irrelevant sigs and so on,
otherwise threads can easily get impossible to understand after a few posts in
this list. Thanks.)

If you can't modify the CGI programs then what can you modify? I'm not sure what
you mean by 'manually'. You could alter Apache's httpd.conf and add

PerlSetEnv PERL5LIB /usr/local/lib/perl5/5.00503

but do you have access to the server setup?

HTH,

Rob


Randal L. Schwartz

2006-10-04, 9:57 pm

>>>>> "narmadha" == narmadha palanisamy <narmadha.palanisamy@wipro.com> writes:

narmadha> I am newbie to the perl.
narmadha> I have installed DBI perl module in FreeBSD under this directory
narmadha> /usr/local/lib/perl5/5.00503.

Why did you do that when it wasn't one of the libraries that your
Perl binary is looking for? Also, why 5.5.3, when you're obviously
running 5.8.7?

If you use the CPAN.pm module to install DBI, it will build it properly
and install it into the "site_perl" directories for your machine.

Do that instead.

You *cannot* change the default @INC. If you want to run unmodified
programs with locally installed modules, those modules *must* be installed
in the listed directories.

narmadha> The information contained in this electronic message and any
narmadha> attachments to this message are intended for the exclusive use of
narmadha> the addressee(s) and may contain proprietary, confidential or
narmadha> privileged information. If you are not the intended recipient, you
narmadha> should not disseminate, distribute or copy this e-mail. Please
narmadha> notify the sender immediately and destroy all copies of this message
narmadha> and any attachments.

Please either:
(a) turn off this disclaimer
or (b) subscribe from an address that doesn't do this

These disclaimers are unenforcable, and just plain annoying.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
Andy Greenwood

2006-10-04, 9:57 pm

How did you install the module? you should be able to just

# cd /usr/ports/databases/p5-DBI/ && make install clean

and it'll work like a charm. That's all I did. For modules that exist
in the ports tree, I find that installing them this way is cleaner
than perl -MCPAN -e "install foo::bar" because the freebsd package
management tools will update everything for you. Note that if you have
a different version of the module installed in
/usr/local/lib/perl5/5.00503, they might conflict. I'd remove that and
start over.

On 04 Oct 2006 07:01:50 -0700, Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>
> narmadha> I am newbie to the perl.
>
> narmadha> I have installed DBI perl module in FreeBSD under this directory
> narmadha> /usr/local/lib/perl5/5.00503.
>
> Why did you do that when it wasn't one of the libraries that your
> Perl binary is looking for? Also, why 5.5.3, when you're obviously
> running 5.8.7?
>
> If you use the CPAN.pm module to install DBI, it will build it properly
> and install it into the "site_perl" directories for your machine.
>
> Do that instead.
>
> You *cannot* change the default @INC. If you want to run unmodified
> programs with locally installed modules, those modules *must* be installed
> in the listed directories.
>
> narmadha> The information contained in this electronic message and any
> narmadha> attachments to this message are intended for the exclusive use of
> narmadha> the addressee(s) and may contain proprietary, confidential or
> narmadha> privileged information. If you are not the intended recipient, you
> narmadha> should not disseminate, distribute or copy this e-mail. Please
> narmadha> notify the sender immediately and destroy all copies of this message
> narmadha> and any attachments.
>
>
> Please either:
> (a) turn off this disclaimer
> or (b) subscribe from an address that doesn't do this
>
> These disclaimers are unenforcable, and just plain annoying.
>
> --
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
> <merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
> See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>



--
I'm nerdy in the extreme and whiter than sour cream
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com