in reply to time in mod_perl

It's hard to find because it's hard to know how to phrase the question. I suspect it's a scoping issue. The mod_perl environment is sometimes a little surprising in that respect. If you post some of the code it'd probably be a lot easier to figure out.

My initial guess is that you're using Apache::Registry in a way that exposes you to closures by accident. I first started with mod_perl by converting existing CGIs into mod_perl apps with a handler like this:

# <Files ~ ".pl$"> # SetHandler perl-script # PerlHandler Apache::Registry # </Files>

If I recall correctly, it was wrapping my whole .pl file in a big function and causing strange things to happen. I got the hang of it after a while, but not until I read things like Closures and scope, Closures question, and more.

I had a bunch of nice articles bookmarked that explained the problem really well, but they seem to have disappeared on me. ikegami explains it really well below anyway.

-Paul

Replies are listed 'Best First'.
Re^2: time in mod_perl
by Bruce32903 (Scribe) on Mar 27, 2007 at 19:13 UTC
    I'm looking through this scope response and the following Apache::Registry response. Both look very interesting and it's nice to have a suggestions to think about rather than just hitting my head on the wall some more.

    My program is 20+ pages and most of it contains material I can not post. I took a few minutes to write a test program and I can not (yet) explain why my test program DOES WORK and my main code does not. Chances are, one of these two responses has the answer.

    My small test code that DOES WORK is:
    #!/usr/bin/perl # FILE: test_time_01.pl use warnings; use strict; use CGI qw(:standard escapeHTML); my $t = time; print start_multipart_form(-action => url()), p header(), start_html("test"), p ("The value of time is $t. &lt;br&gt;&lt;br&gt;"), end_form();

    Thank you,
    Bruce

    Edit: g0n - code tags

      Right, it's like ikegami says then. That my $t = time isn't really in the global scope like you'd imagine. It's wrapped in a function ref that's stored in the handler (or something close to that).

      -Paul

      Thank you to everyone.

      When I pass my time variables to the subroutines it seems to work. Thus, it is a scope issue. I still don't know if there is a deeper wisdom here that I should be seeking or if I should just pass all variables with mod_perl and move on. Either way, I am back on track for this project.

      Thank you,
      Bruce