sub hash_display_listing{ # my $ref = @_; my ($ref) = @_; # or # my $ref = shift ; #### $sth->execute($searchterm) or die "Unable to execute query: " . $sth->errstr; warn("Finished sub search record"); $result = generateResponseHash($sth); #### elsif ($action eq "updatetable_167"){ warn("Entered updatetable_167"); my $kind = $query->param('kind'); die "ERROR \$kind='$kind'" if ($kind < 0 || $kind > 2 ); my $searchterm = $query->param('searchterm'); warn("\$searchterm = '$searchterm'"); my $searchfield = ['userid','lastname','business']->[$kind]; warn("\$searchfield = '$searchfield'"); my $stmt = "SELECT * FROM users WHERE $searchfield = ?"; warn("\$stmt = '$stmt'"); my $sth = $dbh->prepare($stmt); $sth->execute($searchterm); warn("Finished sub search record"); my $count = $sth->rows; warn("\$count = '$count'"); if ($count == 0) { warn("Failed Search: '$searchfield' equal to '$searchterm' "); } else { my $ref = $sth->fetchrow_hashref(); my $hashref = hash_display_listing($ref); completeResultHash( $hashref ); } $sth->finish (); } sub hash_display_listing{ my ($ref) = @_; my %hash = %$ref; print Dumper \%hash; return \%hash; } sub completeResultHash{ my $hashref = shift; warn("completeResultHash line 631"); my $json_str = encode_json($hashref); print $json_str; warn("after jason_str print"); }