dbTalk Databases Forums  

Unitialized value in string

mailing.database.msql-mysql-modules mailing.database.msql-mysql-modules


Discuss Unitialized value in string in the mailing.database.msql-mysql-modules forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Dan Jones
 
Posts: n/a

Default Unitialized value in string - 10-16-2003 , 06:03 PM






I'm writing a script to print out all of the tables in a database and
the column descriptions of each table. So far, I have the following:


#!/usr/bin/perl -w

use DBI;

my $sqldriver = DBI->install_driver('mysql');

my $dbh = DBI->connect('DBI:mysql:books:localhost', 'name', 'password');

if(!$dbh) {
die "Can't find database!";
}

$tables = $dbh->selectall_arrayref('show tables;');

foreach $table(@$tables){
print "\n\n@$table\n";
$columns = $dbh->selectall_arrayref("show columns from @$table");
foreach $column(@$columns){
print "@$column\n"; #line 19
}
}



The output I get is:

Author
Use of uninitialized value in join or string at ./printtables.pl line
19.
AuthorID int(11) PRI auto_increment
LastName varchar(50)
Use of uninitialized value in join or string at ./printtables.pl line
19.
FirstName varchar(50) YES
Use of uninitialized value in join or string at ./printtables.pl line
19.
MiddleName varchar(50) YES


Binding
Use of uninitialized value in join or string at ./printtables.pl line
19.
BindingID int(11) PRI auto_increment
Use of uninitialized value in join or string at ./printtables.pl line
19.
BindingType varchar(25) YES

....


What is causing the "Use of unititialized value..." errors?


--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=ms...ie.nctu.edu.tw


Reply With Quote
  #2  
Old   
Jochen Wiedmann
 
Posts: n/a

Default Re: Unitialized value in string - 10-17-2003 , 12:02 AM






Dan Jones wrote:

Quote:
Use of uninitialized value in join or string at ./printtables.pl line
19.
Most probably you have NULL values in your table, which are translated
to nulls. Try replacing

print "@$column\n";

with

print join("", map{defined($_) ? $_ : ""} @$columns), "\n";


Jochen


P.S: And do not forget to 'use "strict"' :-)


--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=ms...ie.nctu.edu.tw



Reply With Quote
Reply




Thread Tools
Display Modes

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

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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.