v3.22 release
[perl/plp/.git] / lib / PLP.pm
index 03c4acbe38a48d40b5b4eda076ea591a19951081..54a3b91fe5eb43248f81a9f4716478e1fd6f5e43 100644 (file)
@@ -12,8 +12,9 @@ use File::Basename ();
 use File::Spec;
 
 use strict;
 use File::Spec;
 
 use strict;
+use warnings;
 
 
-our $VERSION = '3.19';
+our $VERSION = '3.22';
 
 # Subs in this package:
 #  _default_error($plain, $html)    Default error handler
 
 # Subs in this package:
 #  _default_error($plain, $html)    Default error handler
@@ -82,7 +83,7 @@ sub error {
 # Wrap old request handlers.
 sub everything {
        require PLP::Backend::CGI;
 # Wrap old request handlers.
 sub everything {
        require PLP::Backend::CGI;
-       PLP::Backend::CGI::everything();
+       PLP::Backend::CGI->everything();
 }
 sub handler {
        require PLP::Backend::Apache;
 }
 sub handler {
        require PLP::Backend::Apache;
@@ -93,7 +94,10 @@ sub handler {
 sub sendheaders () {
        $PLP::sentheaders ||= [ caller 1 ? (caller 1)[1, 2] : (caller)[1, 2] ];
        print STDOUT "Content-Type: text/plain\n\n" if $PLP::DEBUG & 2;
 sub sendheaders () {
        $PLP::sentheaders ||= [ caller 1 ? (caller 1)[1, 2] : (caller)[1, 2] ];
        print STDOUT "Content-Type: text/plain\n\n" if $PLP::DEBUG & 2;
-       print STDOUT map("$_: $PLP::Script::header{$_}\n", keys %PLP::Script::header), "\n";
+       while (my ($header, $values) = each %PLP::Script::header) {
+               print STDOUT "$header: $_\n" for split /\n/, $values;
+       }
+       print STDOUT "\n";
 }
 
 {
 }
 
 {
@@ -235,10 +239,10 @@ sub start {
 
                # No lexicals may exist at this point.
                
 
                # No lexicals may exist at this point.
                
-               eval qq{ package PLP::Script; $PLP::code; };
+               eval qq{ package PLP::Script; no warnings; $PLP::code; };
                PLP::error($@, 1) if $@ and $@ !~ /\cS\cT\cO\cP/;
 
                PLP::error($@, 1) if $@ and $@ !~ /\cS\cT\cO\cP/;
 
-               eval   { package PLP::Script; $_->() for reverse @PLP::END };
+               eval   { package PLP::Script; no warnings; $_->() for reverse @PLP::END };
                PLP::error($@, 1) if $@ and $@ !~ /\cS\cT\cO\cP/;
        }
        PLP::sendheaders() unless $PLP::sentheaders;
                PLP::error($@, 1) if $@ and $@ !~ /\cS\cT\cO\cP/;
        }
        PLP::sendheaders() unless $PLP::sentheaders;
@@ -260,15 +264,11 @@ PLP - Perl in HTML pages
 
 F<lighttpd.conf> configuration using L<mod_fastcgi|PLP::Backend::FastCGI>:
 
 
 F<lighttpd.conf> configuration using L<mod_fastcgi|PLP::Backend::FastCGI>:
 
-    server.modules = (
-        "mod_fastcgi",
-    )
-    fastcgi.server = (
-        ".plp" => ((
-                    "bin-path" => "/usr/bin/perl -MPLP::Backend::FastCGI",
-                    "socket" => "/tmp/fcgi-plp.socket",
-                  )),
-    )
+    server.modules += ("mod_fastcgi")
+    fastcgi.server += (".plp" => ((
+        "bin-path" => "/usr/bin/perl -MPLP::Backend::FastCGI",
+        "socket"   => "/tmp/fcgi-plp.socket",
+    )))
 
 =head2 Apache installation
 
 
 =head2 Apache installation
 
@@ -364,14 +364,18 @@ These are described in L<PLP::Functions>.
 
 =over 22
 
 
 =over 22
 
-=item $ENV{PLP_NAME}
+=item $ENV{SCRIPT_NAME}
 
 The URI of the PLP document, without the query string. (Example: C</foo.plp>)
 
 
 The URI of the PLP document, without the query string. (Example: C</foo.plp>)
 
-=item $ENV{PLP_FILENAME}
+Used to be renamed to C<$ENV{PLP_NAME}>, which is still provided but deprecated.
+
+=item $ENV{SCRIPT_FILENAME}
 
 The filename of the PLP document. (Example: C</var/www/index.plp>)
 
 
 The filename of the PLP document. (Example: C</var/www/index.plp>)
 
+C<$ENV{PLP_SCRIPT}> also still provided but deprecated.
+
 =item $PLP::VERSION
 
 The version of PLP.
 =item $PLP::VERSION
 
 The version of PLP.
@@ -403,8 +407,9 @@ These are described in L<PLP::Fields>.
 Not only syntax is important, you should also be aware of some other important
 features. Your script runs inside the package C<PLP::Script> and shouldn't
 leave it. This is because when your script ends, all global variables in the
 Not only syntax is important, you should also be aware of some other important
 features. Your script runs inside the package C<PLP::Script> and shouldn't
 leave it. This is because when your script ends, all global variables in the
-C<PLP::Script> package are destroyed, which is very important if you run under
-mod_perl (they would retain their values if they weren't explicitly destroyed).
+C<PLP::Script> package are destroyed, which is very important if you run a
+persistent backend (they would retain their values if they weren't explicitly
+destroyed).
 
 Until your first output, you are printing to a tied filehandle C<PLPOUT>. On
 first output, headers are sent to the browser and C<STDOUT> is selected for
 
 Until your first output, you are printing to a tied filehandle C<PLPOUT>. On
 first output, headers are sent to the browser and C<STDOUT> is selected for
@@ -416,13 +421,13 @@ line your output started. An alternative way of setting headers is using Perl's
 BEGIN blocks. BEGIN blocks are executed as soon as possible, before anything
 else.
 
 BEGIN blocks. BEGIN blocks are executed as soon as possible, before anything
 else.
 
-Because the interpreter that mod_perl uses never ends, C<END { }> blocks won't
-work properly. You should use C<PLP_END { };> instead. Note that this is a not
-a built-in construct, so it needs proper termination with a semi-colon (as do
-C<eval> and C<do>).
+Unless you're running as CGI, the interpreter won't exit after processing a page,
+so C<END { }> blocks won't work properly.  You should use C<PLP_END { };> instead.
+Note that this is a not a built-in construct, so it needs proper termination
+with a semi-colon (as do C<eval> and C<do>).
 
 
-Under mod_perl, modules are loaded only once. A good modular design can improve
-performance because of this, but you will have to B<reload> the modules
+When run persistently, modules are loaded only once. A good modular design can
+improve performance because of this, but you will have to B<reload> the modules
 yourself when there are newer versions. 
 
 The special hashes are tied hashes and do not always behave the way you expect,
 yourself when there are newer versions. 
 
 The special hashes are tied hashes and do not always behave the way you expect,