<?xml version="1.0" encoding="windows-1252"?>
<node id="994885" title="Re: Converting scalar value to hash" created="2012-09-21 07:43:43" updated="2012-09-21 07:43:43">
<type id="11">
note</type>
<author id="664508">
philipbailey</author>
<data>
<field name="doctext">
&lt;p&gt;You don't tell us what the argument to your &lt;c&gt;handler&lt;/c&gt; subroutine is, although it is evidently an object of some type, as you call a &lt;c&gt;print&lt;/c&gt; method on it. Since we do not know what &lt;c&gt;$r&lt;/c&gt; is, we can only guess what arguments its &lt;c&gt;print&lt;/c&gt; method accepts.&lt;/p&gt;
&lt;p&gt;Your code:&lt;/p&gt;
&lt;c&gt;$r-&gt;print({
                'response' =&gt; {'result' =&gt; $results,},
     });&lt;/c&gt;
&lt;p&gt;calls &lt;c&gt;print&lt;/c&gt; 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 &lt;i&gt;directly&lt;/i&gt; 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:&lt;/p&gt;
&lt;c&gt;$r-&gt;print(response =&gt; {result =&gt; $results});&lt;/c&gt;
&lt;p&gt;Whether this works for you depends on what exactly the object &lt;c&gt;$r&lt;/c&gt; is.&lt;/p&gt;</field>
<field name="root_node">
994880</field>
<field name="parent_node">
994880</field>
</data>
</node>
