v3.25 release
[perl/plp/.git] / lib / PLP.pm
index 2c6d7142d320b5969f8928224fb5a60372ae5182..58120fa55a1820d5c115380c92d0dfcd105b1296 100644 (file)
@@ -14,7 +14,7 @@ use File::Spec;
 use strict;
 use warnings;
 
-our $VERSION = '3.21';
+our $VERSION = '3.25';
 
 # Subs in this package:
 #  _default_error($plain, $html)    Default error handler
@@ -76,7 +76,9 @@ sub error {
                print "Status: $type\nContent-Type: text/html\n\n",
                        qq{<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\n<html>},
                        "<head>\n<title>$type $short</title>\n</head></body>\n<h1>$short",
-                       "</h1>\n$long<p>\n<hr>\n$ENV{SERVER_SIGNATURE}</body></html>";
+                       "</h1>\n$long<p>\n<hr>\n";
+               print $ENV{SERVER_SIGNATURE} if $ENV{SERVER_SIGNATURE};
+               print "</body></html>";
        }
 }
 
@@ -92,6 +94,7 @@ sub handler {
 
 # Sends the headers waiting in %PLP::Script::header
 sub sendheaders () {
+       local $\;  # reset print behaviour if triggered by say()
        $PLP::sentheaders ||= [ caller 1 ? (caller 1)[1, 2] : (caller)[1, 2] ];
        print STDOUT "Content-Type: text/plain\n\n" if $PLP::DEBUG & 2;
        while (my ($header, $values) = each %PLP::Script::header) {
@@ -407,8 +410,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
-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
@@ -420,13 +424,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.
 
-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,
@@ -446,7 +450,7 @@ Originally by Juerd Waalboer <juerd@cpan.org>
 
 =head1 LICENSE
 
-Copyright (c) 2000-2002 Juerd Waalboer, 2005-2008 Mischa POSLAWSKY.
+Copyright (c) 2000-2002 Juerd Waalboer, 2005-2018 Mischa POSLAWSKY.
 All rights reserved.
 
 This software is free software;