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?
: $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.
HTH,
Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>