J
John
Hi
I am reading a row of hashes from a MySQL table.
I need to add that row to an array to create an 'array of hashes'
I should then be able to access, say, $xyz[34]{'steel'}.
The following is part of the code:
my @xyz=({}); # array of hashes
$sql="SELECT coal,iron,steel,china,wool,cloth,fish,livestock FROM industry";
$sth=$dbh->prepare($sql);
$sth->execute or die "Unable to execute query: $dbh->errstr\n";
my $row;
while ($row = $sth->fetchrow_hashref) {push (@xyz,$row)}
$sth->finish();
$dbh- >disconnect();
print $xyz[6]{'cloth'};
The print statement is empty. Any ideas?
Regards
John
I am reading a row of hashes from a MySQL table.
I need to add that row to an array to create an 'array of hashes'
I should then be able to access, say, $xyz[34]{'steel'}.
The following is part of the code:
my @xyz=({}); # array of hashes
$sql="SELECT coal,iron,steel,china,wool,cloth,fish,livestock FROM industry";
$sth=$dbh->prepare($sql);
$sth->execute or die "Unable to execute query: $dbh->errstr\n";
my $row;
while ($row = $sth->fetchrow_hashref) {push (@xyz,$row)}
$sth->finish();
$dbh- >disconnect();
print $xyz[6]{'cloth'};
The print statement is empty. Any ideas?
Regards
John