http://qs321.pair.com?node_id=994885


in reply to Converting scalar value to hash

You don't tell us what the argument to your handler subroutine is, although it is evidently an object of some type, as you call a print method on it. Since we do not know what $r is, we can only guess what arguments its print method accepts.

Your code:

$r->print({ 'response' => {'result' => $results,}, });

calls print with a an anonymous hash reference as the sole argument, which appears to have been stringified by that method, and you indicate that is not what you want. Perl does not actually allow hashes to be directly passed as arguments to subroutines: you can either pass a reference to a hash (which didn't have the behaviour you wanted in this case) or provide a list of alternating key/value pairs, which can be turned into a hash by the subroutine (if it is written that way). The latter would look like this:

$r->print(response => {result => $results});

Whether this works for you depends on what exactly the object $r is.