PERL 10
Modperl_extra_startup.pl Guest on 8th November 2020 06:55:11 AM
  1. use strict;
  2. use warnings FATAL => 'all';
  3.  
  4. use ModPerl::RegistryLoader ();
  5.  
  6. use Apache2::ServerRec ();
  7. use Apache2::ServerUtil ();
  8. use Apache2::Process ();
  9.  
  10. use DirHandle ();
  11.  
  12. my $proc = Apache2::ServerUtil->server->process;
  13. my $pool = $proc->pool;
  14.  
  15. # can't use catfile with server_root as it contains unix dir
  16. # separators and in a few of our particular tests we compare against
  17. # win32 separators. in general avoid using server_root_relative in your
  18. # code, see the manpage for more details
  19. my $base_dir = Apache2::ServerUtil::server_root_relative($pool, "cgi-bin");
  20.  
  21. # test the scripts pre-loading by explicitly specifying uri => filename
  22. my $rl = ModPerl::RegistryLoader->new(package => "ModPerl::Registry");
  23. my $base_uri = "/cgi-bin";
  24. for my $file (qw(basic.pl env.pl)) {
  25.     my $file_path = "$base_dir/$file";
  26.     my $uri       = "$base_uri/$file";
  27.     $rl->handler($uri, $file_path);
  28. }
  29.  
  30.  
  31. # test the scripts pre-loading by using trans sub
  32. {
  33.     sub trans {
  34.         my $uri = shift;
  35.         $uri =~ s|^/registry_bb/|cgi-bin/|;
  36.         return Apache2::ServerUtil::server_root_relative($pool, $uri);
  37.     }
  38.  
  39.     my $rl = ModPerl::RegistryLoader->new(
  40.         package => "ModPerl::RegistryBB",
  41.         trans   => \&trans,
  42.     );
  43.  
  44.     my @preload = qw(basic.pl env.pl require.pl special_blocks.pl
  45.                      redirect.pl 206.pl content_type.pl);
  46.  
  47.     for my $file (@preload) {
  48.         $rl->handler("/registry_bb/$file");
  49.     }
  50. }
  51.  
  52. 1;

Paste is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.