LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Perl and mysql - warnings??? (http://www.linuxquestions.org/questions/programming-9/perl-and-mysql-warnings-848039/)

barriehie 12-02-2010 08:04 PM

Perl and mysql - warnings???
 
Hello and thank you for reading my post. I've decided to learn perl and have an application that is going to require the use of mysql. Are these warnings bad??? Here's the code:
Code:

#!/usr/bin/perl -w

#
# Utility script to sequentially number vim backup files.
# Script is called via a bash daemon using inotifywait to
# detect the presence of some_file_name~ in vim's backup
# directory.
#
# Requires: Run as user.
#

use lib '/usr/lib/perl5/DBD';
require "mysql.pm";

#
# Variables
#
$server = "localhost";
$host = "localhost";
$database = "vimbup";
$table_name = "vbackup";
$user = "**********";
$pass = "**********";

#
# C O N N E C T  T O  T H E  D A T A B A S E
#
my $dbh  = DBI->connect ("DBI:mysql:database=$database:host=$host", $user, $pass,
                          {
                                        PrintError => 1,  ### Don't report errors via warn(  )
                                        RaiseError => 1    ### Do report errors via die(  )
                          } ) or die "Can't connect to database: $DBI::errstr\n";


#@files = </home/barrie/.vim/backup/*~>;
#foreach $file (@files) {
#    print $file . "\n";
#}

And the warnings:
Code:

$ > ./vimb.pl
Name "DBI::errstr" used only once: possible typo at ./vimb.pl line 32.
Name "main::server" used only once: possible typo at ./vimb.pl line 18.
Name "main::table_name" used only once: possible typo at ./vimb.pl line 21.
Subroutine driver redefined at /usr/lib/perl5/DBD/mysql.pm line 21.
Subroutine CLONE redefined at /usr/lib/perl5/DBD/mysql.pm line 38.
Subroutine _OdbcParse redefined at /usr/lib/perl5/DBD/mysql.pm line 42.
Subroutine _OdbcParseHost redefined at /usr/lib/perl5/DBD/mysql.pm line 77.
Subroutine AUTOLOAD redefined at /usr/lib/perl5/DBD/mysql.pm line 84.
Subroutine connect redefined at /usr/lib/perl5/DBD/mysql.pm line 103.
Subroutine data_sources redefined at /usr/lib/perl5/DBD/mysql.pm line 151.
Subroutine admin redefined at /usr/lib/perl5/DBD/mysql.pm line 169.
Subroutine prepare redefined at /usr/lib/perl5/DBD/mysql.pm line 217.
Subroutine db2ANSI redefined at /usr/lib/perl5/DBD/mysql.pm line 231.
Subroutine ANSI2db redefined at /usr/lib/perl5/DBD/mysql.pm line 237.
Subroutine admin redefined at /usr/lib/perl5/DBD/mysql.pm line 243.
Subroutine _SelectDB redefined at /usr/lib/perl5/DBD/mysql.pm line 252.
Subroutine table_info redefined at /usr/lib/perl5/DBD/mysql.pm line 256.
Subroutine _ListTables redefined at /usr/lib/perl5/DBD/mysql.pm line 386.
Subroutine column_info redefined at /usr/lib/perl5/DBD/mysql.pm line 395.
Subroutine primary_key_info redefined at /usr/lib/perl5/DBD/mysql.pm line 586.
Subroutine foreign_key_info redefined at /usr/lib/perl5/DBD/mysql.pm line 633.
Subroutine _version redefined at /usr/lib/perl5/DBD/mysql.pm line 714.
Subroutine get_info redefined at /usr/lib/perl5/DBD/mysql.pm line 727.

Thank you and appreciate any input!

jodyman 12-03-2010 12:44 AM

You are loading the mysql module twice.

After the #! line use:

Code:

use strict;
use DBI;

No need for:

Code:

use lib '/usr/lib/perl5/DBD';
require "mysql.pm";

your DBI->connect ("DBI:mysql:database=$database:host=$host", $user, $pass,

uses and calls the proper DBD::mysql module.

barriehie 12-03-2010 02:43 AM

Thank you jodyman, that solved it!


All times are GMT -5. The time now is 03:52 AM.