CthuMP wrote:
> I have follow simple script:
> !#/usr/bin/perl
>
> print "Content-Type: text/html\n\n";
>
> print "Counter: " . (++$counter) . "\n";
> print time(), "\n";
>
> sleep(20);
>
> print time(), "\n";
>
> Starting that script twice in two different browser windows gives me same
> results. In second window I start script after some period (about 10
> seconds) after first script started. First and Second scripts ends at the
> same time.
> So, I misunderrstand, why results are same?
>

If you're actually seeing the same results from the 'print time()'
calls, something weird is going on. A proxy server between you and the
server might cause that i suppose, or something the browser is doing
with caching, but that shouldn't really happen at the server end i don't
think (unless there is some sort of caching mechanism going on there too.

> As I see it, apache must give work to second child processes for second
> request (because first busy). And scripts must end works in different time
> (first script in 10 seconds before second) and give different results (same
> counter result, but different times).
>

That sounds accurate to me

> Even if script runs sequentially for each request, results will difference
> and second script ends after 30 seconds (10 remained for 1st script and 20
> for 2nd). But it is not!
> If I copy script and run two same scripts with different names it works
> fine.
>
>
> Second question about childs. I not fully understand, how childs work. One
> child can handle only one script? It's important, because if one child can
> handle different scripts, than module global variables saves their values
> between different script calls.
> For example, if script1 and script2 uses module My::TestPackage, first
> script sets $My::TestPackage::variable = 123, then script2, after it
> request, will see in $My::TestPackage::variable value 123, but I haven't
> seen mention about that situation in official documentations.
>

Each apache child will handle any and all scripts. You can't reliably
share global variables like that for exactly the reason you mention.
Generally, if you're running code under mod_perl you should be running
it under 'use strict' (which would break your original example).

Adam