LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-18-2009, 03:37 AM   #1
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 707

Rep: Reputation: 55
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.......
 
Old 06-18-2009, 04:05 AM   #2
Janine08
LQ Newbie
 
Registered: Jun 2009
Posts: 1

Rep: Reputation: 0
I'm having the same problem. I hope someone could answer us here.
 
Old 06-18-2009, 05:21 AM   #3
jmcmillan
LQ Newbie
 
Registered: Jun 2003
Posts: 13

Rep: Reputation: 0
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.
 
Old 06-18-2009, 06:50 AM   #4
Su-Shee
Member
 
Registered: Sep 2007
Location: Berlin
Distribution: Slackware
Posts: 510

Rep: Reputation: 53
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.
 
Old 06-18-2009, 07:06 AM   #5
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 707

Original Poster
Rep: Reputation: 55
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....

Last edited by vinaytp; 06-18-2009 at 07:07 AM.
 
Old 06-18-2009, 07:18 AM   #6
Su-Shee
Member
 
Registered: Sep 2007
Location: Berlin
Distribution: Slackware
Posts: 510

Rep: Reputation: 53
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
AWK a variable Ouptut to a new variable and using the new variable with the old one alertroshannow Linux - Newbie 4 02-16-2009 12:08 AM
Sed search for variable and delete entire line, but variable contains forward /'s Passions Programming 2 11-10-2008 03:44 PM
function showing a list of variable and value: (dynamic variable name) budhax Linux - Newbie 1 09-19-2008 07:05 PM
Help: removing a variable substring from a string variable in sh script gnparsons Programming 2 06-04-2008 05:21 PM
setting a variable variable in a script... this works, but could it be more elegant? pwc101 Programming 3 08-18-2006 11:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration