X-Git-Url: http://git.shiar.net/perl/plp/.git/blobdiff_plain/0f5e78a789961923b45cae1a881c655fff9e7283..4cbac41f4d1bef193cf955c6c854c8a9ed258119:/PLP/Functions.pm diff --git a/PLP/Functions.pm b/PLP/Functions.pm index 9d7b33c..e07caa5 100644 --- a/PLP/Functions.pm +++ b/PLP/Functions.pm @@ -4,20 +4,34 @@ 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 ($) { - my ($file) = $_[0]; + no strict; + $PLP::file = $_[0]; $PLP::inA = 0; $PLP::inB = 0; - eval PLP::source($file, 0); + local $@; + eval 'package PLP::Script; ' . PLP::source($PLP::file, 0, join ' ', (caller)[2,1]); + 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; @@ -119,8 +133,8 @@ sub WriteFile ($$) { sub Counter ($) { local *COUNTER; local $/ = undef; - open COUNTER, "+<$_[0]" or - open COUNTER, ">$_[0]" or return undef; + open COUNTER, '+<', $_[0] or + open COUNTER, '>', $_[0] or return undef; flock COUNTER, 2; seek COUNTER, 0, 0; my $counter = ;