Andrew Gaffney <[EMAIL PROTECTED]> wrtoe:
: foreach (keys %$tabledesc) { : foreach (keys %$tabledesc->{$_}) {
Shouldn't that be:
foreach ( keys %{ $tabledesc->{$_} } ) {
: print "$_ = $tabledesc->{$_}, "; : } : print "\n"; : }
BTW, it's confusing to use nested loops which both use the default value ($_). You would probably be better off with named values or just not using two loops.
use Data::Dumper 'Dumper';
print Dumper $tabledesc;
I changed it to:
foreach my $field (keys %$tabledesc) { print "${field} - "; foreach (keys %{ $tabledesc->{$field} }) { print "$_ = $tabledesc->{$field}->{$_}, "; } print "\n"; }
which makes it a tad less confusing (and also makes it work). 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 '->'.
$tabledesc = {}; $sth = $dbh->prepare("DESCRIBE $_"); $sth->execute; while($ref = $sth->fetchrow_hashref) { -> $tabledesc->{$ref->{Field}} = {type => "$ref->{Type}", null => "$ref->{Null}", key => "$ref->{Key}", default => "$ref->{Default}", extra => "$ref->{Extra}" }; }
-- 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>