comparison Lib/IMPL/require.pm @ 252:34a3f8668b58

fixed IMPL::require IMPL::declare
author sergey
date Mon, 19 Nov 2012 01:28:58 +0400
parents 9f394b27dccf
children 0f59b2de72af
comparison
equal deleted inserted replaced
251:9f394b27dccf 252:34a3f8668b58
15 15
16 die "A hash reference is required" unless ref $aliases eq 'HASH'; 16 die "A hash reference is required" unless ref $aliases eq 'HASH';
17 17
18 my $caller = caller; 18 my $caller = caller;
19 19
20 $PENDING{$caller} = 1;
21
20 no strict 'refs'; 22 no strict 'refs';
21 23
22 while( my ($alias, $class) = each %$aliases ) { 24 while( my ($alias, $class) = each %$aliases ) {
23 _trace("$alias => $class"); 25 _trace("$alias => $class");
24 $level++; 26 $level++;
29 $class 31 $class
30 }, ''); 32 }, '');
31 33
32 $level--; 34 $level--;
33 } 35 }
36
37 delete $PENDING{$caller};
34 } 38 }
35 39
36 sub _require { 40 sub _require {
37 my ($class) = @_; 41 my ($class) = @_;
38 42
39 if ( not $class =~ s/^-// ) { 43 if ( not $class =~ s/^-// ) {
40 ( my $file = $class ) =~ s/::|'/\//g; 44 ( my $file = $class ) =~ s/::|'/\//g;
41 _trace("already pending") and return 45 _trace("already pending") and return $class
42 if $PENDING{$class}; 46 if $PENDING{$class};
43 $PENDING{$class} = 1; 47 $PENDING{$class} = 1;
44 _trace("loading $file.pm"); 48 _trace("loading $file.pm");
45 $level++; 49 $level++;
46 require "$file.pm"; 50 require "$file.pm";