perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Torsten Foertsch <torsten.foert...@gmx.net>
Subject Re: [MP2] possible pnotes bug?
Date Mon, 09 Jan 2006 20:08:48 GMT
On Monday 09 January 2006 20:22, John ORourke wrote:
> 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

Another workaround is this:

sub Apache2::RequestRec::save_pnotes {
  my $r=shift;
  $r->pnotes(@_==2 ? ($_[0], my $x=$_[1]) : @_);
}

or even this:

BEGIN {
  my $pn=\&Apache2::RequestRec::pnotes;
  *Apache2::RequestRec::pnotes=sub {
    my $r=shift;
    $r->$pn(@_==2 ? ($_[0], my $x=$_[1]) : @_);
  }
}

But my intend was to point out what seemed to me like a bug. The only hint I 
found in the docs for the behavior is the word "Share" in:

       "Share Perl variables between Perl HTTP handlers"


Torsten

Mime
View raw message