perl-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Torsten Foertsch <>
Subject Re: [MP2] possible pnotes bug?
Date Tue, 06 Jun 2006 09:58:48 GMT

some time ago there was an argument about the "right" behavior of pnotes, see

The question was whether $r->pnotes(key=>value) should do exactly the same as 
$r->pnotes->{key}=value or for some historical reason not.

The problem is that after:

my $foo = 123;

and storing $foo as a pnote:

$r->pnotes('foo' => $foo);

any subsequent changes on $foo like $foo=456 affect also the pnote and changes 
to the pnote like $r->pnotes->{foo}++ affect $foo.

Otherwise, if the pnote is stored as:


subsequent changes to either $foo or $pnotes->{foo} don't affect the other 

Back then one fraction said the behavior is right as it is now because it was 
so also in mp1 and because such a change is not to be done within a stable 
release-cycle. The other saw it this way, for the user both ways of setting a 
pnote look identical, hence they should behave identical.

What is the common understanding on this point by now?

I think a possible fix is as simple as this:

Index: src/modules/perl/modperl_util.c
--- src/modules/perl/modperl_util.c     (revision 412021)
+++ src/modules/perl/modperl_util.c     (working copy)
@@ -889,7 +889,7 @@
         char *k = SvPV(key, len);

         if (val) {
-            retval = *hv_store(*pnotes, k, len, SvREFCNT_inc(val), 0);
+            retval = *hv_store(*pnotes, k, len, newSVsv(val), 0);
         else if (hv_exists(*pnotes, k, len)) {
             retval = *hv_fetch(*pnotes, k, len, FALSE);


View raw message