I have a pretty complete install of RH7, with MySQL 3.23.32 running well
and all.
The last time I was writing Perl programs was on an Alpha box, so I've
never actually ran them yet on this RH Linux box.
I'm going through Paul DuBois' MySQL book (so far, all good). Got to
Perl section, and entered his first Perl example, named "dump_members"
from Chpt. 7. (see bottom of email)
I've checked my coding, and it looks identical to what's in DuBois's
book (except user, password, etc)
Oh -- I have also previously tried to install the DBI and DBD modules by
using.. (the installs looked good, incidentally)
# perl -MCPAN -e 'install DBI'
# perl -MCPAN -e 'install DBD::mysql'
First-- the message I'm getting when I try to run the Perl script is as
follows
[root@cx631025-h cgi-bin]# ./dump_members.pl
install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC (@INC
contains: /usr/lib/perl5/5.6.0/i386-linux /usr/lib/perl5/5.6.0
/usr/lib/perl5/site_perl/5.6.0/i386-linux /usr/lib/perl5/site_perl/5.6.0
/usr/lib/perl5/site_perl .) at (eval 1) line 3.
Perhaps the DBD::mysql perl module hasn't been fully installed,
or perhaps the capitalisation of 'mysql' isn't right.
Available drivers: ADO, ExampleP, Multiplex, Proxy.
at ./dump_members.pl line 15
You have new mail in /var/spool/mail/root
[root@cx631025-h cgi-bin]#
Second-- I've tried reinstalling these modules... as root, as my normal
username -- but almost everytime, using this MCPAN install, everything
looks good, it goes through the connections, and finally ends with the
"# /usr/bin/make install -- ok". In fact, when I try to reinstall DBI
through MCPAN, I get a brief connection, then the message "Already
successfully installed" (that's not quite verbatim, but very close)
This is one of the first road blocks I've ran into using Perl, and also
the first going through the book -- please advise -- anyone??
Thanks all
Just in case, I've pasted my program below, except for the password, of
course
[root@cx631025-h cgi-bin]# more dump_members.pl
#! /usr/bin/perl
# dump_members - dump Historical League's membership list
use DBI;
use strict;
my ($dsn) = "DBI:mysql:samp_db:localhost"; # data source name
my ($user_name) = "aweeks"; # user name
my ($password) = "*******"; # password
my ($dbh, $sth); # database and statement handles
my (@ary); # array for rows returned by query
# connect to database
$dbh = DBI->connect ($dsn, $user_name, $password, { RaiseError => 1 });
# issue query
$sth = $dbh->prepare ("SELECT last_name, first_name, suffix, email,"
. "street, city, state, zip, phone FROM member ORDER BY last_name");
$sth->execute ();
# read results of query, then clean up
while (@ary = $sth->fetchrow_array ())
{
print join ("\t", @ary), "\n";
}
$sth->finish ();
$dbh->disconnect ();
exit (0);