Charles K. Clarkson wrote:
Andrew Gaffney <[EMAIL PROTECTED]> wrote:

: Now I've got another issue. : How can I dynamically assign new keys to a hash without
: getting warnings when using 'use warnings'? I get the warning
: about an undefined value on the line with the '->'.



You can either temporarily turn those warnings off (not a good idea) or you can make certain undefined values are not used. The big question would be: Why is '$sth->fetchrow_hashref' returning at least one undefined value?

It looks like not all of the fields have something in them. Perl is taking blanks for undefined for some reason.


:    $tabledesc = {};
:    $sth = $dbh->prepare("DESCRIBE $_");
:    $sth->execute;
:    while($ref = $sth->fetchrow_hashref) {

    Are you sure your DB returns Field, Type, Null, Key, Default,
and Extra on every field? Perhaps a more general approach would
work:

my $field = delete $ref->{Field};

$tabledesc->{ $field } = $ref;

: ->  $tabledesc->{$ref->{Field}} = {type    => "$ref->{Type}",
:                                     null    => "$ref->{Null}",
:                                     key     => "$ref->{Key}",
:                                     default => "$ref->{Default}",
:                                     extra   => "$ref->{Extra}" };

     What are the double quotes for? You're forcing
stringification (perlfaq4). That's usually a bad idea.

I was trying to get rid of another warning:


Use of uninitialized value in concatenation (.) or string at ./modtables.pl line 26.

Which is the line where it prints out the values in the hash. It gives me that when the field is blank, the same as it give me the other warning with the quotes.

--
Andrew Gaffney
Network Administrator
Skyline Aeronautics, LLC.
636-357-1548


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to