File Coverage

blib/lib/Exporter.pm
Criterion Covered Total %
statement 0 43 0.0
branch 0 16 0.0
condition 0 32 0.0
subroutine 0 9 0.0
pod 0 7 0.0
total 0 107 0.0


line stmt bran cond sub pod time code
1             package Exporter;
2              
3             use strict;
4             no strict 'refs';
5              
6             our $Debug = 0;
7             our $ExportLevel = 0;
8             our $Verbose ||= 0;
9             our $VERSION = '5.77';
10             our %Cache;
11              
12             sub as_heavy {
13 0     0 0   require Exporter::Heavy;
14             # Unfortunately, this does not work if the caller is aliased as *name = \&foo
15             # Thus the need to create a lot of identical subroutines
16 0           my $c = (caller(1))[3];
17 0           $c =~ s/.*:://;
18 0           \&{"Exporter::Heavy::heavy_$c"};
  0            
19             }
20              
21             sub export {
22 0     0 0   goto &{as_heavy()};
  0            
23             }
24              
25             sub import {
26 0     0     my $pkg = shift;
27 0           my $callpkg = caller($ExportLevel);
28              
29 0 0 0       if ($pkg eq "Exporter" and @_ and $_[0] eq "import") {
      0        
30 0           *{$callpkg."::import"} = \&import;
  0            
31 0           return;
32             }
33              
34             # We *need* to treat @{"$pkg\::EXPORT_FAIL"} since Carp uses it :-(
35 0           my $exports = \@{"$pkg\::EXPORT"};
  0            
36             # But, avoid creating things if they don't exist, which saves a couple of
37             # hundred bytes per package processed.
38 0   0       my $fail = ${$pkg . '::'}{EXPORT_FAIL} && \@{"$pkg\::EXPORT_FAIL"};
39 0 0 0       return export $pkg, $callpkg, @_
      0        
      0        
40             if $Verbose or $Debug or $fail && @$fail > 1;
41 0   0       my $export_cache = ($Cache{$pkg} ||= {});
42 0 0         my $args = @_ or @_ = @$exports;
43              
44 0 0 0       if ($args and not %$export_cache) {
45             s/^&//, $export_cache->{$_} = 1
46 0           foreach (@$exports, @{"$pkg\::EXPORT_OK"});
  0            
47             }
48 0           my $heavy;
49             # Try very hard not to use {} and hence have to enter scope on the foreach
50             # We bomb out of the loop with last as soon as heavy is set.
51 0 0 0       if ($args or $fail) {
52             ($heavy = (/\W/ or $args and not exists $export_cache->{$_}
53             or $fail and @$fail and $_ eq $fail->[0])) and last
54 0   0       foreach (@_);
      0        
55             } else {
56             ($heavy = /\W/) and last
57 0   0       foreach (@_);
58             }
59 0 0         return export $pkg, $callpkg, ($args ? @_ : ()) if $heavy;
    0          
60             local $SIG{__WARN__} =
61 0 0   0     sub {require Carp; &Carp::carp} if not $SIG{__WARN__};
  0            
  0            
62             # shortcut for the common case of no type character
63 0           *{"$callpkg\::$_"} = \&{"$pkg\::$_"} foreach @_;
  0            
  0            
64             }
65              
66             # Default methods
67              
68             sub export_fail {
69 0     0 0   my $self = shift;
70 0           @_;
71             }
72              
73             # Unfortunately, caller(1)[3] "does not work" if the caller is aliased as
74             # *name = \&foo. Thus the need to create a lot of identical subroutines
75             # Otherwise we could have aliased them to export().
76              
77             sub export_to_level {
78 0     0 0   goto &{as_heavy()};
  0            
79             }
80              
81             sub export_tags {
82 0     0 0   goto &{as_heavy()};
  0            
83             }
84              
85             sub export_ok_tags {
86 0     0 0   goto &{as_heavy()};
  0            
87             }
88              
89             sub require_version {
90 0     0 0   goto &{as_heavy()};
  0            
91             }
92              
93             1;
94             __END__