summaryrefslogtreecommitdiff
path: root/lib/SelfLoader.pm
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>2000-06-01 07:41:02 +0000
committerGurusamy Sarathy <gsar@cpan.org>2000-06-01 07:41:02 +0000
commitbfdd149997f4a56ec34c947f0d733ecbfb53a519 (patch)
tree09498a5275161db9ea7a768e41348f6a55472441 /lib/SelfLoader.pm
parentd658dc55c1a5a1e82545e617134daabc3276b047 (diff)
downloadperl-bfdd149997f4a56ec34c947f0d733ecbfb53a519.tar.gz
SelfLoader can lose $@ in AUTOLOAD() (from Nicholas Clark
<nick@ccl4.org>) p4raw-id: //depot/perl@6183
Diffstat (limited to 'lib/SelfLoader.pm')
-rw-r--r--lib/SelfLoader.pm5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/SelfLoader.pm b/lib/SelfLoader.pm
index 99372f2630..3b9c52d912 100644
--- a/lib/SelfLoader.pm
+++ b/lib/SelfLoader.pm
@@ -3,7 +3,7 @@ package SelfLoader;
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(AUTOLOAD);
-$VERSION = "1.0901";
+$VERSION = "1.0902";
sub Version {$VERSION}
$DEBUG = 0;
@@ -20,6 +20,7 @@ sub croak { require Carp; goto &Carp::croak }
AUTOLOAD {
print STDERR "SelfLoader::AUTOLOAD for $AUTOLOAD\n" if $DEBUG;
my $SL_code = $Cache{$AUTOLOAD};
+ my $save = $@; # evals in both AUTOLOAD and _load_stubs can corrupt $@
unless ($SL_code) {
# Maybe this pack had stubs before __DATA__, and never initialized.
# Or, this maybe an automatic DESTROY method call when none exists.
@@ -31,11 +32,13 @@ AUTOLOAD {
croak "Undefined subroutine $AUTOLOAD" unless $SL_code;
}
print STDERR "SelfLoader::AUTOLOAD eval: $SL_code\n" if $DEBUG;
+
eval $SL_code;
if ($@) {
$@ =~ s/ at .*\n//;
croak $@;
}
+ $@ = $save;
defined(&$AUTOLOAD) || die "SelfLoader inconsistency error";
delete $Cache{$AUTOLOAD};
goto &$AUTOLOAD