I’m having a lot of trouble getting past this point in a Perl script that takes user input search criteria and searches our publications and formats the output. I’ve inserted debug print statements in to discover the SQL statement is exactly what I want. When I replace the fetchrow_hashref and the call to the display_listing routine with:
while (my @row= $sth->fetchrow_array ())
print “$row $row $row $row
I get the correct but unformatted data.
I can’t seem to get anything out to the original hash. I must have a fundamental misunderstanding about how hashes work. What would be a way to insert a diagnostic dump of the hash contents before I jump into the display_listing?
The code in part:
#$col_list = “*”;#
WHERE clause listing the conditions
$where = "WHERE
ID) AND “
. join (” AND ", @condition) if @condition;
$where = “” unless $where;
$stmt = “SELECT DISTINCT
ORDER BY Year LIMIT 100”;
print “condition array = “, @condition,”\n\n”;
print “placeholder array = “, @placeholder,”\n\n”;
print “where statement = $where\n\n”;
print “SQL statement = $stmt\n\n”;
$sth = $dbh->prepare ($stmt);
$count = $sth->rows;
while (my $ref = $sth->fetchrow_hashref ())
print (“Sorry, no qualifying listings were found.”) if !$count;
This signature line intentionally blank.