David Gray,
Thanks for the input. Below is another realization using a pseudohash.
Some of the code (print stmts at the end)
is there to demonstrate concepts (the way your post did).
my $sql = "select methodid, method, sname from method order by methodid";
my $sth = $dbh->prepare($sql) or die "Prepare fails for
stmt:\n\t\t$sql\nError = ", $DBI::errstr;
my $rv;
unless ($sth->execute) {
print"\n\tExecute fails for stmt:\n\t\t$sql\nError = ", $DBI::errstr;
$sth->finish;
$dbh->disconnect;
die "\n\t\tClean up finished\n";
}
print "\t\t$rv\n\n" if $rv;
my %row_ary;
my $row_ary;
my $key;
my $i = 0;
my @array_of_Hrefs;
my $href;
# The select * from method (above)
# and the while loop puts the contents of the
# method table into a hash whose key is the
# column name and value is the column contents
while ($row_ary = $sth->fetchrow_hashref) {
$array_of_Hrefs[$i++] = $row_ary;
}
$sth->finish;
$dbh->disconnect;
$i = 0;
# see Programming Perl page 255
my $phash = \@array_of_Hrefs;
for(my $j = 0;$j < 12;$j++) {
print "\n\t\t\t\$j = $j\n\tKey\t\tValue\n";
foreach $key ('methodid', 'method', 'sname' ) {
print"\t$key \t\t$phash->[$j]{$key}";
print"\n";
}
}
print $phash->[0]{methodid}."\n";
print $phash->[1]{method}."\n";
print $phash->[3]."\n";
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]