Loading ...
Sorry, an error occurred while loading the content.

Re: [BUG] Inconsistent $r->print() behavior with references

Expand Messages
  • Jonathan Field
    ... I was surprised that the SCALAR(0x8ca70e4) output was identical on subsequent requests to a child -- indicating to me that the ref (and what it was
    Message 1 of 35 , Dec 2, 2003
    • 0 Attachment
      > I'm not sure what you mean here.
      > Note that *variables* are lexically scoped, but not values.

      I was surprised that the "SCALAR(0x8ca70e4)" output was identical on
      subsequent requests to a child -- indicating to me that the ref (and what
      it was refering to) may have survived the request cycle? I guess would
      have expected a different ref, especially after running through the top
      part of the handler again, where it reinitializes them. I've included the
      code again below for convenience).

      Also, the internal magic (switching from PV to PVMG) seems to survive the
      request cycle? Regardlesss of whether the $r->print() behavior is going
      to be changed, I was surprised that the regex from first request effected
      the behavior on the second request.

      Just my thoughts as a curious mortal :)

      Thanks,
      Jonathan

      ---

      sub handler {

      my $r = shift;
      $r->send_http_header("text/plain");

      my $data = "hello\n";
      my $dataref = \$data;

      # normally we can pass a reference to Apache's print
      $r->print($dataref);

      $$dataref =~ s/(h)/$1/;

      # but not if we've done a successful backreferenced pattern match
      $r->print($dataref);

      }

      1;

      On the first request to a given child, I get:

      hello
      SCALAR(0x8ca70e4)

      On subsequent requests I get:

      SCALAR(0x8ca70e4)SCALAR(0x8ca70e4)





      --
      Reporting bugs: http://perl.apache.org/bugs/
      Mail list info: http://perl.apache.org/maillist/modperl.html
    • Jonathan Field
      Thanks, all, for the prompt attention. I will update my coding habits accordingly :) Cheers ... -- Reporting bugs: http://perl.apache.org/bugs/ Mail list
      Message 35 of 35 , Dec 10, 2003
      • 0 Attachment
        Thanks, all, for the prompt attention. I will update my coding habits
        accordingly :)

        Cheers

        On Wed, 10 Dec 2003, Stas Bekman wrote:

        > I've pinged Doug and the final verdict is this:
        >
        > The print-a-scalar-reference feature is now deprecated. There are
        > known bugs when using it and it's not supported by mod_perl 2.0. If
        > you have a scalar reference containing a string to be printed,
        > dereference it before sending it to print.
        >
        > It's now documented as such.
        >
        > Jonathan, please adjust your code to dereference the scalar references before
        > sending them to print.
        >
        > __________________________________________________________________
        > Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
        > http://stason.org/ mod_perl Guide ---> http://perl.apache.org
        > mailto:stas@... http://use.perl.org http://apacheweek.com
        > http://modperlbook.org http://apache.org http://ticketmaster.com
        >


        --
        Reporting bugs: http://perl.apache.org/bugs/
        Mail list info: http://perl.apache.org/maillist/modperl.html
      Your message has been successfully submitted and would be delivered to recipients shortly.