-   Programming (
-   -   Perl and mysql - warnings??? (

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:

#!/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 "";

# 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:

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


use strict;
use DBI;

No need for:


use lib '/usr/lib/perl5/DBD';
require "";

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.