LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   where @INC variable is located (https://www.linuxquestions.org/questions/linux-newbie-8/where-%40inc-variable-is-located-733831/)

vinaytp 06-18-2009 03:37 AM

where @INC variable is located
 
hi all.......

when i try to execute a perl script like

use mysql;
$host='localhost';
$database = "new";
$user = "root";
$pw = "";
$connect = mysql->connect($host, $database, $user, $pw);
my $sth = $connect->prepare("desc hello");
$sth->execute;

i am getting error Can't locate mysql.pm in @INC (@INC contains: /usr/lib/perl5/5.10.........

but mysql.pm is located in /usr/lib/perl5/vendor_perl/5.10.0/i386-linux-thread-multi/Bundle/DBD/mysql.pm

but i dont know where @INC variable is there to add this path


can anyone please help me......

Thanks in advance.......

Janine08 06-18-2009 04:05 AM

I'm having the same problem. I hope someone could answer us here.

jmcmillan 06-18-2009 05:21 AM

Hello Vinaytp,

@INC is an array which perl uses to find modules.


You could try adding the following to your script.

Code:

use lib '/usr/lib/perl5/vendor_perl/5.10.0/i386-linux-thread-multi/Bundle/DBD/';
Hope that helps.

Su-Shee 06-18-2009 06:50 AM

First, print what your @INC contains exactly:

perl -e "print @INC;"

and before you actually change it, make sure that you use Perl's DBD::mysql the right way which would be via DBI - as described in the perldoc page of DBD::mysql (perldoc DBD::mysql)


http://search.cpan.org/~capttofu/DBD...b/DBD/mysql.pm

You'll have to have DBI AND DBD::mysql installed. DBI is a so called "core module" which means

As Perl's DBI interface is more or less always used the same way (despite the SQL dialects spoken to the database), please check one of the many, many available tutorials, you'll easily find with Google.

There's also a nice book by O'Reilly's.

vinaytp 06-18-2009 07:06 AM

hi all....

Thanks for the replies...
I found the answer... here i have to set the environmental variable

PERL5LIB='/usr/lib/perl5/vendor_perl/5.10.0/i386-linux-thread-multi'

where DBI.pm package is located, then it worked
better define this path in /etc/bashrc
and execute source /etc/bashrc so that this path is available to all users....

Su-Shee 06-18-2009 07:18 AM

If your Perl is installed correctly and you just use CPAN or install a module via "perl Makefile.PL" you don't have to touch @INC, because Perl knows its own module path.

Please install the modules correctly first before you touch @INC or change PERL5PATH.


All times are GMT -5. The time now is 02:29 AM.