git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Running gitweb under mod_perl

From
Jakub Narebski <jnareb@gmail.com>
Date
Aug 24, 2006, 20:59 UTC
Message-ID
<ecl3v4$s14$1@sea.gmane.org>
In-Reply-To
<20060824193220.G4a28fdc4@leonov.stosberg.net>
Dennis Stosberg wrote:
Show 19 quoted lines
> 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.

Show 6 quoted lines
> 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. 
Show 16 quoted lines
> 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
Previous: Dennis StosbergNext: Randal L. Schwartz
Message 11 of 12 in “Running gitweb under mod_perl”
  1. Jakub NarebskiAug 24, 2006
  2. Johannes SchindelinAug 24, 2006
  3. Dennis StosbergAug 24, 2006
  4. gitweb: Use --git-dir parameter instead of setting $ENV{'GIT_DIR'}Dennis Stosberg, Aug 24, 2006
  5. gitweb: Use --git-dir parameter instead of setting $ENV{'GIT_DIR'}Jakub Narebski, Aug 28, 2006
  6. Dennis StosbergAug 29, 2006
  7. use do() instead of require() to include configurationDennis Stosberg, Aug 29, 2006
  8. Jakub NarebskiSep 5, 2006
  9. Jakub NarebskiAug 24, 2006
  10. Dennis StosbergAug 24, 2006
  11. Jakub NarebskiAug 24, 2006
  12. Randal L. SchwartzAug 25, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.