git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: git@vger.kernel.org
Subject: Re: Running gitweb under mod_perl
Date: Thu, 24 Aug 2006 22:59:18 +0200	[thread overview]
Message-ID: <ecl3v4$s14$1@sea.gmane.org> (raw)
In-Reply-To: 20060824193220.G4a28fdc4@leonov.stosberg.net

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

  reply	other threads:[~2006-08-24 21:00 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-24 12:43 Running gitweb under mod_perl Jakub Narebski
2006-08-24 12:46 ` Johannes Schindelin
2006-08-24 14:05 ` Dennis Stosberg
2006-08-24 15:12   ` [PATCH] gitweb: Use --git-dir parameter instead of setting $ENV{'GIT_DIR'} Dennis Stosberg
2006-08-28 15:49     ` [PATCH (amend)] " Jakub Narebski
2006-08-29  7:18       ` Dennis Stosberg
2006-08-29  7:19       ` [PATCH] use do() instead of require() to include configuration Dennis Stosberg
2006-09-05 20:32   ` Running gitweb under mod_perl Jakub Narebski
2006-08-24 17:49 ` Jakub Narebski
2006-08-24 19:32   ` Dennis Stosberg
2006-08-24 20:59     ` Jakub Narebski [this message]
2006-08-25  1:13       ` Randal L. Schwartz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='ecl3v4$s14$1@sea.gmane.org' \
    --to=jnareb@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).