fix header output triggered by say() in perl 5.10.1+
authorMischa POSLAWSKY <perl@shiar.org>
Sat, 17 Oct 2009 05:45:59 +0000 (07:45 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Mon, 19 Oct 2009 01:03:46 +0000 (01:03 +0000)
Since the latest Perl release, calling sendheaders() from within a say()
would (correctly) retain a custom output seperator, resulting in http
headers being sent incorrectly.

Easily fixed by resetting normal printing behaviour.

lib/PLP.pm

index 2e740cfaa5ab2b156571a0390f92458807c5c06c..680dba821372fdf582468e10361e17936ce5e41e 100644 (file)
@@ -94,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) {