LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-02-2010, 07:04 PM   #1
barriehie
Member
 
Registered: Nov 2010
Distribution: Debian Lenny
Posts: 136
Blog Entries: 1

Rep: Reputation: 23
Question 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!
 
Old 12-02-2010, 11:44 PM   #2
jodyman
LQ Newbie
 
Registered: Oct 2010
Location: Medina, OH
Distribution: Ubuntu Lucid 10.04
Posts: 1

Rep: Reputation: 1
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.
 
1 members found this post helpful.
Old 12-03-2010, 01:43 AM   #3
barriehie
Member
 
Registered: Nov 2010
Distribution: Debian Lenny
Posts: 136

Original Poster
Blog Entries: 1

Rep: Reputation: 23
Thank you jodyman, that solved it!
 
  


Reply

Tags
mysql, perl



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
Bugzilla - MySQL - perl - DBD::mysql install problem amchargue Linux - Software 3 09-10-2008 12:01 AM
[SOLVED] [php and mysql]mysql warnings Wim Sturkenboom Programming 5 04-16-2008 07:27 AM
Bugzilla - MySQL - perl - DBD::mysql install problem Runningonair Linux - Software 8 10-12-2007 12:42 AM
warnings on perl doronunu Programming 8 05-02-2006 07:09 AM
Error compiling perl-DBD-MySQL after upgrading to MySQL 4.1 pitaro920 Linux - Software 1 01-16-2006 04:28 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:00 AM.

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