use base 'Exporter';
use strict;
-our @EXPORT = qw/HiddenFields Entity DecodeURI EncodeURI Entity include
- AddCookie ReadFile WriteFile AutoURL Counter Include/;
+our @EXPORT = qw/HiddenFields Entity DecodeURI EncodeURI Entity include PLP_END
+ AddCookie ReadFile WriteFile AutoURL Counter Include exit/;
sub Include ($) {
no strict;
$PLP::inB = 0;
local $@;
eval 'package PLP::Script; ' . PLP::source($PLP::file, 0, join ' ', (caller)[2,1]);
- PLP::error($@, 1) if $@;
+ if ($@) {
+ PLP::Functions::exit if $@ =~ /\cS\cT\cO\cP/;
+ PLP::error($@, 1);
+ }
}
sub include ($) {
goto &Include;
}
+sub exit (;$) {
+ die "\cS\cT\cO\cP\n";
+}
+
+sub PLP_END (&) {
+ push @PLP::END, shift;
+}
+
sub HiddenFields ($@) {
my $hash = shift;
my %saves;
use PLP;
use strict;
-die 'Wrong module version' if $PLP::VERSION ne '3.05';
+die 'Wrong module version' if $PLP::VERSION ne '3.06';
{
+ @PLP::END = ();
$PLP::code = '';
$PLP::sentheaders = 0;
$PLP::inA = 0;
*cookies = \%cookie;
PLP::Functions->import();
# No lexicals may exist at this point.
- eval qq{package PLP::Script; $PLP::code};
+ eval qq{ package PLP::Script; $PLP::code; };
+ PLP::error($@, 1) if $@ and $@ !~ /\cS\cT\cO\cP/;
+ eval { package PLP::Script; $_->() for reverse @PLP::END };
+ PLP::error($@, 1) if $@ and $@ !~ /\cS\cT\cO\cP/;
}
- PLP::error($@, 1) if $@;
+ PLP::sendheaders() unless $PLP::sentheaders;
select STDOUT;
undef *{"PLP::Script::$_"} for keys %PLP::Script::;
- PLP::sendheaders() unless $PLP::sentheaders;
}