Torsten wasn't changing the value pointed to by $ctx, he was changing $ctx - therefore it looks like pnotes actually stores a reference to the scalar you give it, instead of the actual scalar itself as the docs imply. So I'd say it's a doc bug, but I'd prefer pnotes to store the actual scalar instead.

Torsten - for a workaround try not re-using $ctx until it's gone out of scope, like this:

               $r->content_type('text/plain');
               {
                       my $tmp={one=>1,two=>2};
                       $r->pnotes('x',$tmp);
               }
               {
                       my $tmp='nothing';
                       print Dumper($r->pnotes('x'))."\n------------\n";
               }
               print Dumper($r->pnotes('x')); # prints the same hash


Clint Edwards wrote:

Torsten,

Yes this is expected, $ctx contains a reference to an anonymous hash,
and when you store the value of $ctx in your pnotes, you are merely
storing another reference, therefore whenever the values pointed to by
$ctx change, you effectively change what is seen in pnotes.

Reply via email to