代码之家  ›  专栏  ›  技术社区  ›  Jakub Narębski adamtaub

如何使用mod perl::registry(mod_perl handler)检测Perl中的Web脚本是否运行?

  •  4
  • Jakub Narębski adamtaub  · 技术社区  · 14 年前

    是否可以在中检测在mod perl下运行的web应用程序,如果使用 ModPerl::Registry ?

    1 回复  |  直到 14 年前
        1
  •  4
  •   Greg Bacon    14 年前

    注册中心做了一个精心设计的舞蹈,将您的代码与系统中的其他任何东西隔离开来,其中的一部分就是将它编译成下面的一个包 ModPerl::ROOT .

    当在列表上下文中使用指定要返回的帧数的参数调用时, caller 收益率

    #  0         1          2      3            4
    ($package, $filename, $line, $subroutine, $hasargs,
    #  5          6          7            8       9         10
    $wantarray, $evaltext, $is_require, $hints, $bitmask, $hinthash)
     = caller($i); 
    

    何处 $subroutine 值是完全限定名。

    modperl::registry将整个程序包装在名为 handler 在前面提到的人工包中,因此从主程序中,使用类似于

    my $name = (caller 0)[3];
    if ($name =~ /^ModPerl::ROOT::/) {
      # run using ModPerl::Registry
      ...
    }