⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 apache2::perlsections.3

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 3
📖 第 1 页 / 共 2 页
字号:
\&    $My::tar = 7;\&  </Perl>.Ve.PPThe local global variable \f(CW$foo\fR becomes\&\f(CW$Apache2::ReadConfig::tmp::httpd_conf::line_20::foo\fR, the othervariable remain where they are..PPBy default, the namespace in which \f(CW\*(C`<Perl>\*(C'\fR sections areevaluated is cleared after each block closes. In our example nuking\&\f(CW$Apache2::ReadConfig::tmp::httpd_conf::line_20::foo\fR, leaving therest untouched..PPBy setting \f(CW$Apache2::PerlSections::Save\fR to a true value, the contentof those namespaces will be preserved and will be available forinspection by \f(CW\*(C`Apache2::Status\*(C'\fR and\&\f(CW\*(C`Apache2::PerlSections\->dump\*(C'\fRIn our example \f(CW$Apache2::ReadConfig::tmp::httpd_conf::line_20::foo\fRwill still be accessible from other perl code, after the\&\f(CW\*(C`<Perl>\*(C'\fR section was parsed..SH "PerlSections Dumping".IX Header "PerlSections Dumping".ie n .Sh """Apache2::PerlSections\->dump""".el .Sh "\f(CWApache2::PerlSections\->dump\fP".IX Subsection "Apache2::PerlSections->dump"This method will dump out all the configuration variables mod_perlwill be feeding to the apache config gears. The output is suitable toread back in via \f(CW\*(C`eval\*(C'\fR..PP.Vb 1\&  my $dump = Apache2::PerlSections\->dump;.Ve.ie n .IP "ret: $dump\fR ( string / \f(CW""undef"" )" 4.el .IP "ret: \f(CW$dump\fR ( string / \f(CWundef\fR )" 4.IX Item "ret: $dump ( string / undef )"A string dump of all the Perl code encountered in <Perl> blocks,suitable to be read back via \f(CW\*(C`eval\*(C'\fR.PPFor example:.PP.Vb 1\&  <Perl>\&  \&  $Apache2::PerlSections::Save = 1;\&  \&  $Listen = 8529;\&  \&  $Location{"/perl"} = {\&     SetHandler => "perl\-script",\&     PerlHandler => "ModPerl::Registry",\&     Options => "ExecCGI",\&  };\&  \&  @DirectoryIndex = qw(index.htm index.html);\&  \&  $VirtualHost{"www.foo.com"} = {\&     DocumentRoot => "/tmp/docs",\&     ErrorLog => "/dev/null",\&     Location => {\&       "/" => {\&         Allowoverride => \*(AqAll\*(Aq,\&         Order => \*(Aqdeny,allow\*(Aq,\&         Deny  => \*(Aqfrom all\*(Aq,\&         Allow => \*(Aqfrom foo.com\*(Aq,\&       },\&     },\&  };\&  </Perl>\&  \&  <Perl>\&  print Apache2::PerlSections\->dump;\&  </Perl>.Ve.PPThis will print something like this:.PP.Vb 1\&  $Listen = 8529;\&  \&  @DirectoryIndex = (\&    \*(Aqindex.htm\*(Aq,\&    \*(Aqindex.html\*(Aq\&  );\&  \&  $Location{\*(Aq/perl\*(Aq} = (\&      PerlHandler => \*(AqApache2::Registry\*(Aq,\&      SetHandler => \*(Aqperl\-script\*(Aq,\&      Options => \*(AqExecCGI\*(Aq\&  );\&  \&  $VirtualHost{\*(Aqwww.foo.com\*(Aq} = (\&      Location => {\&        \*(Aq/\*(Aq => {\&          Deny => \*(Aqfrom all\*(Aq,\&          Order => \*(Aqdeny,allow\*(Aq,\&          Allow => \*(Aqfrom foo.com\*(Aq,\&          Allowoverride => \*(AqAll\*(Aq\&        }\&      },\&      DocumentRoot => \*(Aq/tmp/docs\*(Aq,\&      ErrorLog => \*(Aq/dev/null\*(Aq\&  );\&  \&  1;\&  _\|_END_\|_.Ve.PPIt is important to put the call to \f(CW\*(C`dump\*(C'\fR in it's own \f(CW\*(C`<Perl>\*(C'\fRsection, otherwise the content of the current \f(CW\*(C`<Perl>\*(C'\fR sectionwill not be dumped..ie n .Sh """Apache2::PerlSections\->store""".el .Sh "\f(CWApache2::PerlSections\->store\fP".IX Subsection "Apache2::PerlSections->store"This method will call the \f(CW\*(C`dump\*(C'\fR method, writing the outputto a file, suitable to be pulled in via \f(CW\*(C`require\*(C'\fR or \f(CW\*(C`do\*(C'\fR..PP.Vb 1\&  Apache2::PerlSections\->store($filename);.Ve.ie n .IP "arg1: $filename (string)" 4.el .IP "arg1: \f(CW$filename\fR (string)" 4.IX Item "arg1: $filename (string)"The filename to save the dump output to.IP "ret: no return value" 4.IX Item "ret: no return value".SH "Advanced API".IX Header "Advanced API"mod_perl 2.0 now introduces the same general concept of handlers to\&\f(CW\*(C`<Perl>\*(C'\fR sections.  Apache2::PerlSections simply being thedefault handler for them..PPTo specify a different handler for a given perl section, an extrahandler argument must be given to the section:.PP.Vb 4\&  <Perl handler="My::PerlSection::Handler" somearg="test1">\&    $foo = 1;\&    $bar = 2;\&  </Perl>.Ve.PPAnd in My/PerlSection/Handler.pm:.PP.Vb 4\&  sub My::Handler::handler : handler {\&      my ($self, $parms, $args) = @_;\&      #do your thing!\&  }.Ve.PPSo, when that given \f(CW\*(C`<Perl>\*(C'\fR block in encountered, the codewithin will first be evaluated, then the handler routine will beinvoked with 3 arguments:.ie n .IP "arg1: $self" 4.el .IP "arg1: \f(CW$self\fR" 4.IX Item "arg1: $self"self-explanatory.ie n .IP "arg2: $parms\fR ( \f(CW""Apache2::CmdParms"" )" 4.el .IP "arg2: \f(CW$parms\fR ( \f(CWApache2::CmdParms\fR )" 4.IX Item "arg2: $parms ( Apache2::CmdParms )"\&\f(CW$parms\fR is specific for the current Container, for example, youmight want to call \f(CW\*(C`$parms\->server()\*(C'\fR to get the current server..ie n .IP "arg3: $args\fR ( \f(CW""APR::Table object"")" 4.el .IP "arg3: \f(CW$args\fR ( \f(CWAPR::Table object\fR)" 4.IX Item "arg3: $args ( APR::Table object)"the table object of the section arguments. The 2 guaranteed ones willbe:.Sp.Vb 2\&  $args\->{\*(Aqhandler\*(Aq} = \*(AqMy::PerlSection::Handler\*(Aq;\&  $args\->{\*(Aqpackage\*(Aq} = \*(AqApache2::ReadConfig\*(Aq;.Ve.SpOther \f(CW\*(C`name="value"\*(C'\fR pairs given on the \f(CW\*(C`<Perl>\*(C'\fR line willalso be included..PPAt this point, it's up to the handler routing to inspect the namespaceof the \f(CW$args\fR\->{'package'} and chooses what to do..PPThe most likely thing to do is to feed configuration data back intoapache. To do that, use Apache2::Server\->add_config(\*(L"directive\*(R"),for example:.PP.Vb 1\&  $parms\->server\->add_config("Alias /foo /bar");.Ve.PPWould create a new alias. The source code of \f(CW\*(C`Apache2::PerlSections\*(C'\fRis a good place to look for a practical example..ie n .SH "Verifying ""<Perl>"" Sections".el .SH "Verifying \f(CW<Perl>\fP Sections".IX Header "Verifying <Perl> Sections"If the \f(CW\*(C`<Perl>\*(C'\fR sections include no code requiring a runningmod_perl, it is possible to check those from the command line. But thefollowing trick should be used:.PP.Vb 3\&  # file: httpd.conf\&  <Perl>\&  #!perl\&  \&  # ... code here ...\&  \&  _\|_END_\|_\&  </Perl>.Ve.PPNow you can run:.PP.Vb 1\&  % perl \-c httpd.conf.Ve.SH "Bugs".IX Header "Bugs".Sh "<Perl> directive missing closing '>'".IX Subsection "<Perl> directive missing closing '>'"httpd\-2.0.47 had a bug in the configuration parser which caused thestartup failure with the following error:.PP.Vb 3\&  Starting httpd:\&  Syntax error on line ... of /etc/httpd/conf/httpd.conf:\&  <Perl> directive missing closing \*(Aq>\*(Aq     [FAILED].Ve.PPThis has been fixed in httpd\-2.0.48. If you can't upgrade to this or ahigher version, please add a space before the closing '>' of theopening tag as a workaround. So if you had:.PP.Vb 3\&  <Perl>\&  # some code\&  </Perl>.Ve.PPchange it to be:.PP.Vb 3\&  <Perl >\&  # some code\&  </Perl>.Ve.Sh "<Perl>[...]> was not closed.".IX Subsection "<Perl>[...]> was not closed."On encountering a one-line <Perl> block, httpd's configuration parser will cause a startupfailure with an error similar to this one:.PP.Vb 3\&  Starting httpd:\&  Syntax error on line ... of /etc/httpd/conf/httpd.conf:\&  <Perl>use> was not closed..Ve.PPIf you have written a simple one-line <Perl>section like this one :.PP.Vb 1\&  <Perl>use Apache::DBI;</Perl>.Ve.PPchange it to be:.PP.Vb 3\&   <Perl>\&   use Apache::DBI;\&   </Perl>.Ve.PPThis is caused by a limitation of httpd's configurationparser and is not likely to be changed to allow one-lineblock like the example above. Use multi-line blocks instead..SH "See Also".IX Header "See Also"mod_perl 2.0 documentation..SH "Copyright".IX Header "Copyright"mod_perl 2.0 and its core modules are copyrighted underThe Apache Software License, Version 2.0..SH "Authors".IX Header "Authors"The mod_perl development team and numerouscontributors.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -