I have a script which creates a hash where all the values are hash references. I'm trying to iterate through the original hash and down into the anonymous hashes to make sure my code is doing what I think it's doing. My problem comes in at those nested foreach loops before the DB disconnect. I get the error:

Using a hash as a reference is deprecated at ./modtables.pl line 24.
Type of arg 1 to keys must be hash (not hash element) at ./modtables.pl line 24, near 
"})"

<code>
#!/usr/bin/perl

use Skyline; # Custom module
use strict;
use warnings;

my @tables;
my $dbh = init_db(); # Custom function to connect to MySQL DB
my ($sth, $ref, $tabledesc);

get_table_list();
foreach (@tables) {
  $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} };
  }
  foreach (keys %$tabledesc) {
    foreach (keys %$tabledesc->{$_}) {
      print "$_ = $tabledesc->{$_}, ";
    }
    print "\n";
  }
}
$dbh->disconnect();

sub get_table_list {
  $sth = $dbh->prepare("SHOW TABLES");
  $sth->execute;
  while($ref = $sth->fetchrow_hashref) {
    push @tables, $ref->{'Tables_in_skyline'} if($ref->{'Tables_in_skyline'} =~ 
/^m\d{6}$/);
  }
}
</code>

--
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