X-Git-Url: http://git.shiar.nl/gitweb.cgi/perl/plp/.git/blobdiff_plain/ef6d542255046b6f50d7047d8e5a1d85b9f01042..refs/tags/3.06:/PLP.pm?ds=sidebyside diff --git a/PLP.pm b/PLP.pm index 78e0dac..03b5b92 100644 --- a/PLP.pm +++ b/PLP.pm @@ -2,7 +2,7 @@ package PLP; # Not to be used without the CGI script; -our $VERSION = '3.02'; +our $VERSION = '3.06'; use PLP::Functions (); use PLP::Fields; @@ -55,7 +55,7 @@ sub source { : qq/\n#line 1 "$file"\nprint q\cQ/; my $linenr = 0; local *SOURCE; - open SOURCE, $path or return $level + open SOURCE, '<', $path or return $level ? qq{\cQ; die qq[Can't open "\Q$path\E" (\Q$!\E)]; print q\cQ} : qq{\n#line $linespec\ndie qq[Can't open "\Q$path\E" (\Q$!\E)];}; LINE: while (defined (my $line = )) { @@ -101,10 +101,11 @@ sub source { sub error { my ($error, $type) = @_; if (not defined $type or $type < 100) { + return undef unless $PLP::DEBUG & 1; + my $plain = $error; + (my $html = $plain) =~ s/([<&>])/'&#' . ord($1) . ';'/ge; PLP::sendheaders unless $PLP::sentheaders; - $error =~ s/([<&>])/'&#' . ord($1) . ';'/ge; - print qq{
}, - qq{Debug information:
$error
}; + $PLP::ERROR->($plain, $html); } else { select STDOUT; my ($short, $long) = @{ +{ @@ -118,6 +119,12 @@ sub error { } } +sub _default_error { + my ($plain, $html) = @_; + print qq{
}, + qq{Debug information:
$html
}; +} + sub start { my $file = $ENV{PATH_TRANSLATED}; $ENV{PLP_NAME} = $ENV{PATH_INFO}; @@ -166,8 +173,10 @@ sub start { chdir $dir; $PLP::code = PLP::source($file, 0); + tie *PLPOUT, 'PLP::Tie::Print'; select PLPOUT; + $PLP::ERROR = \&_default_error; } 1;