I bet you're using an Apache::Registry script with a global my variable.
my $t = time; sub print_t { print("$t\n"); } print_t(); print("$t\n");
This is not a mod_perl problem, but an Apache::Registry problem. Apache::Registry puts your script in a function it executes every time the page is requested.
my $script = sub { my $t = time; sub print_t { print("$t\n"); } print_t(); print("$t\n"); }; $script->(); # A page request sleep(2); $script->(); # A page request
the problem is that print_t closed over $t, so it always refers to $t original value, even though $t changes.
1175021938 1175021938 1175021938 <- print_t still references the original $t 1175021940
The fix is to use package variables instead of lexical variables for globals in Apache::Registry scripts.
my $script = sub { our $t = time; sub print_t { print("$t\n"); } print_t(); print("$t\n"); }; $script->(); # A page request sleep(2); $script->(); # A page request
1175022050 1175022050 1175022052 1175022052
In reply to Re: time in mod_perl
by ikegami
in thread time in mod_perl
by Bruce32903
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |