Mario R. Sanchez, Ph.D. wrote:
> hi pDale
>
> this is the entire code ...
> ============
> while(my $row_href = $sth->fetchrow_hashref)
> {
> print "$row_href->{'area'}\n";
> }
> foreach my $key (keys %$row_href)
> {
> print "hi\n";
> print "$key = ".$row_href->{$key}."\n";
> }
> =================
>
> the "while" correctly outputs the values for the column/field "area"
> - so the hash at that point has the data.
>
> the "foreach" outputs nothing - does not even enter the loop since the
> "hi" does not print....
$row_href is not defined when you are trying to print the keys.
$row_href is only defined inside the while loop.
Try this code:
============
while(my $row_href = $sth->fetchrow_hashref)
{
foreach my $key (keys %$row_href)
{
print "-------------------------------\n";
print "$key = ".$row_href->{$key}."\n";
}
}
=================
--
Bowie
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs