File Coverage

blib/lib/Acme/Pr0n.pm
Criterion Covered Total %
statement 40 40 100.0
branch 10 10 100.0
condition 2 3 66.6
subroutine 4 4 100.0
pod n/a
total 56 57 98.2


line stmt bran cond sub pod time code
1             package Acme::Pr0n;
2              
3 2     2   1832 use strict;
  2         6  
  2         102  
4 2     2   12 use vars '$VERSION';
  2         5  
  2         167  
5              
6             $VERSION = '0.04';
7              
8             sub import
9             {
10 4     4   6580 my $caller = caller();
11              
12 2     2   11 no strict 'refs';
  2         3  
  2         867  
13              
14 4         11 for my $victim (@_)
15             {
16 4         9 ( my $path = $victim ) =~ s[::][/]g;
17 4 100       20 unless ( exists $INC{ $path . '.pm' } )
18             {
19 1         83 require Carp;
20 1         192 Carp::croak("Some pervert is looking at unloaded module $victim!");
21             }
22 3         5 my $glob = *{"main::${victim}::"};
  3         16  
23              
24 3 100 66     17 unless ( exists $glob->{VERSION}
  3         33  
25 3         5 and ${ *{ $glob->{VERSION} }{SCALAR} } >= 0.18 )
26             {
27 1         7 require Carp;
28 1         5 Carp::carp( "Module '$victim' too young!" );
29             }
30              
31 2         6 my @exportlists = grep { exists $glob->{$_} } qw( EXPORT EXPORT_OK );
  4         15  
32              
33 2         5 my %skip;
34 2         5 @skip{ map { @{ *{ $glob->{$_} }{ARRAY} } } @exportlists } = ();
  4         8  
  4         6  
  4         25  
35              
36 2         8 for my $symbol ( keys %$glob )
37             {
38 15         66 for my $slots (
39             [ 'CODE', '&', '' ],
40             [ 'SCALAR', '$' ],
41             [ 'ARRAY', '@' ],
42             [ 'HASH', '%' ],
43             [ 'IO', '*' ],
44             )
45             {
46 75         104 my $slot = shift @$slots;
47 75         176 my $skip_slot = 0;
48 75         149 while (@$slots)
49             {
50 90 100       294 $skip_slot = 1, last
51             if exists $skip{ shift(@$slots) . $symbol };
52             }
53 75 100       143 next if $skip_slot;
54              
55 70 100       69 if ( defined( my $ref = *{ $glob->{$symbol} }{$slot} ) )
  70         316  
56             {
57 22         25 *{ $caller . "::$symbol" } = $ref;
  22         95  
58             }
59             }
60             }
61             }
62             }
63              
64             1;
65              
66             __END__