| 1 | package Namespace::Pollute; | ||||||||||||||
| 2 | { | ||||||||||||||
| 3 | 1 | $Namespace::Pollute::VERSION = '0.002'; | |||||||||||||
| 4 | } | ||||||||||||||
| 5 | # ABSTRACT: Loads and imports the default exported symbols of a list of modules | ||||||||||||||
| 6 | |||||||||||||||
| 7 | 1 | ▶ | use Exporter; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | 1 | @ISA = qw(Exporter); | |||||||||||||
| 9 | |||||||||||||||
| 10 | 1 | ▶ | sub import { | ||||||||||||
|
Subroutine
import: called CC=9 SCAR=22.4
| |||||||||||||||
| 11 | |||||||||||||||
| 12 | 1 | shift; #-- The first one is our own class name | |||||||||||||
| 13 | |||||||||||||||
| 14 | 1 | ▶ | if ( $_[0] eq '-verbose' ) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 15 | 1 | $VERBOSE = 1; | |||||||||||||
| 16 | 1 | shift; | |||||||||||||
| 17 | } | ||||||||||||||
| 18 | |||||||||||||||
| 19 | 1 | foreach my $module (@_) { | |||||||||||||
| 20 | 2 | eval "require $module"; | |||||||||||||
| 21 | |||||||||||||||
| 22 | 2 | ▶ | if ( eval { $module->isa('Exporter') } ) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 23 | 1 | ▶ | print "ISA Exporter: $module\n" if $VERBOSE; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 24 | |||||||||||||||
| 25 | 1 | @EXPORT = @{"${module}::EXPORT"}; | |||||||||||||
| 26 | |||||||||||||||
| 27 | 1 | $module->import(@EXPORT); | |||||||||||||
| 28 | |||||||||||||||
| 29 | 1 | foreach my $symbol (@EXPORT) { | |||||||||||||
| 30 | 3 | ▶ | print "\tExporting: $module::$symbol\n" if $VERBOSE; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 31 | 3 | Namespace::Pollute->export_to_level( 1,, ($symbol) ); | |||||||||||||
| 32 | } | ||||||||||||||
| 33 | |||||||||||||||
| 34 | } elsif ( | ||||||||||||||
| 35 | eval { | ||||||||||||||
| 36 | 1 | $module->can('import'); | |||||||||||||
| 37 | } | ||||||||||||||
| 38 | ) | ||||||||||||||
| 39 | { | ||||||||||||||
| 40 | 1 | ▶ | print "Calling $module->import\n" if $VERBOSE; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 41 | |||||||||||||||
| 42 | #-- Things that have an import sub: | ||||||||||||||
| 43 | 1 | $module->import; | |||||||||||||
| 44 | } | ||||||||||||||
| 45 | } | ||||||||||||||
| 46 | |||||||||||||||
| 47 | } | ||||||||||||||
| 48 | |||||||||||||||
| 49 | 1 | 1; | |||||||||||||
| 50 | |||||||||||||||
| 51 | __END__ | ||||||||||||||