Re: Running gitweb under mod_perl

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dennis Stosberg wrote:

> Jakub Narebski wrote:
> 
>> By the way, does the "static" variables works under mod_perl? i.e.
>> 
>> {
>>   my $private_var = "something"
>> 
>>   sub some_sub {
>>     ...
>>   }
>> 
>>   sub other_sub {
>>     ...
>>   }
>> }
> 
> Depends on what you expect.  The variable will remain shared between
> those subs over successive executions, but it will not be reinitialised
> to "something" -- at least not visibly to the subs:

Well, I wanted to share read-only variable, initialized once and not
changed at all. It could be global variable, but it is used only by
those two functions.

> On the first invocation, $private_var is initialised and the two
> subroutines are created.  Internally, they refer to the _instance_ of
> $private_var.  The next time the script is run by mod_perl, $private_var
> gets initialised again, but the subs are persistent and still refer to
> the old instance.  _Their_ copy of the variable will still be shared
> between them, but it will not be reset to "something".

I don't need to reinitialize $private_var -- it is not changed. 

> Apache::Registry wraps the whole script in another function, which
> is called on each request, so your piece of code really looks somewhat
> like this:
> 
> #!/usr/bin/perl
> sub handler {
>     # do something
>     {
>         my $a = 'A';
>         sub sub_a { $a .= 'B' }
>         sub sub_b { print $a."\n" }
>     }
>     sub_a();
>     sub_b();
> }
> for(1..10) { handler() }

Thanks for an explanation.

Is there any way to check at _runtime_ if script is run under mod_perl,
or would it be simplier (after script reorganization) for install time
selection of using CGI, FastCGI, or Apache2::something...?
-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git


-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]