I've been off this list for over a year, so I may be covering ground that 
I've failed to find in the archives, but whatever...

I've had occasion to examine the internals of Apache::Registry recently[1] 
and have been reminded of the unfeasably long package names that it 
generates for scripts.

It occurs to me that there would be no overhead to speak of in using a 
sequence number, given that Apache::Registry already maintains a hash for 
its generated package names for mtime checks. Something like:

        my $script=
          $Apache::Registry->{$script_name}||=
            {seq => ++$Apache::Registry::seq, mtime => $mtime+1};

        my $package=sprintf "Apache::MAIN::S%04d", $script->{seq};

        $r->log_error("Apache::Registry::handler package $package")
           if $Debug && $Debug & 4;

        $r->chdir_file;

        unless ($script->{mtime} <= $mtime) {
          $script->{mtime}=$mtime;
          $package=sprintf "Apache::MAIN::S%04d", $script->{seq};

          # compile into $package
        }

        my $old_status = $r->status;

        my $cv = \&{"$package\::handler"};
        eval { &{$cv}($r, @_) } if $r->seqno;

        # and so on...

Seems a lot clearer to me than what we now have (particularly if a script 
directory is way down the directory hierarchy), gets round the need for 
name mangling, and the real script name is still there in the file field 
of stack frames for diagnostic purposes.

Pete Jordan

[1] for my Perl exception package (yes, another one :) which, in its 
development version, now mostly does the Right Thing for mod_perl. See 
http://sourceforge.net/projects/perlexception/ for the curious.

Reply via email to