X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSelfLoader.pm;h=87587c31be635bdbd48b7e00302e0f0e4b91d04d;hb=e68ec53fb89aea41859fe8c109fe9b03a3599284;hp=51124af6b49ff94c0fdf7d0aff3d814aa663a26e;hpb=33235a50d090f47e8c1345f546ef4a97abb985d9;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/SelfLoader.pm b/lib/SelfLoader.pm index 51124af..87587c3 100644 --- a/lib/SelfLoader.pm +++ b/lib/SelfLoader.pm @@ -1,21 +1,23 @@ package SelfLoader; -# use Carp; require Exporter; @ISA = qw(Exporter); @EXPORT = qw(AUTOLOAD); -$VERSION = "1.0902"; +$VERSION = "1.0905"; sub Version {$VERSION} $DEBUG = 0; my %Cache; # private cache for all SelfLoader's client packages # allow checking for valid ': attrlist' attachments -my $nested; +# (we use 'our' rather than 'my' here, due to the rather complex and buggy +# behaviour of lexicals with qr// and (??{$lex}) ) +our $nested; $nested = qr{ \( (?: (?> [^()]+ ) | (??{ $nested }) )* \) }x; -my $one_attr = qr{ (?> (?! \d) \w+ (?:$nested)? ) (?:\s*\:\s*|\s+(?!\:)) }x; -my $attr_list = qr{ \s* : \s* (?: $one_attr )* }x; +our $one_attr = qr{ (?> (?! \d) \w+ (?:$nested)? ) (?:\s*\:\s*|\s+(?!\:)) }x; +our $attr_list = qr{ \s* : \s* (?: $one_attr )* }x; sub croak { require Carp; goto &Carp::croak } +sub carp { require Carp; goto &Carp::carp } AUTOLOAD { print STDERR "SelfLoader::AUTOLOAD for $AUTOLOAD\n" if $DEBUG; @@ -113,7 +115,7 @@ sub _load_stubs { sub _add_to_cache { my($self,$fullname,$pack,$lines, $protoype) = @_; return () unless $fullname; - (require Carp), Carp::carp("Redefining sub $fullname") + carp("Redefining sub $fullname") if exists $Cache{$fullname}; $Cache{$fullname} = join('', "package $pack; ",@$lines); print STDERR "SelfLoader cached $fullname: $Cache{$fullname}" if $DEBUG;