File Coverage

blib/lib/Exporter/Cluster.pm
Criterion Covered Total %
statement 8 13 61.5
branch 0 2 0.0
condition n/a
subroutine 2 2 100.0
pod n/a
total 10 17 58.8


line stmt bran cond sub pod time code
1             package Exporter::Cluster;
2             ######################################################################
3             ## ##
4             ## Package: Cluster.pm ##
5             ## Author: D. Hageman ##
6             ## ##
7             ## Description: ##
8             ## ##
9             ## Exporter::Cluster is a module designed to work with Exporter ##
10             ## to bundle or 'cluster' the importing of several modules. ##
11             ## ##
12             ######################################################################
13              
14             ##==================================================================##
15             ## Libraries and Variables ##
16             ##==================================================================##
17              
18             require 5.005; ## This will be the earliest version of Perl we will
19             ## consider supporting with this module.
20              
21 1     1   25289 use warnings;
  1         3  
  1         177  
22              
23             $Exporter::Cluster::VERSION = "0.31";
24              
25             ##==================================================================##
26             ## Function(s) ##
27             ##==================================================================##
28              
29             ##----------------------------------------------##
30             ## import ##
31             ##----------------------------------------------##
32             ## Method that will be inherited by the module ##
33             ## that puts Exporter::Cluster in this ISA. ##
34             ##----------------------------------------------##
35             sub import
36             {
37 1     1   9 my $self = shift;
38            
39             ## We need to find out who is calling us so we can use that
40             ## as the destination of the symbol munging.
41 1         7 my $caller = caller;
42            
43             ## Loop through all of the elements of the EXPORT_CLUSTER hash.
44 1         2 foreach( keys( %{ "$self\::EXPORT_CLUSTER" } ) )
  1         8  
45             {
46             ## Grab the arguments to pass into the import function. We
47             ## clean them up a bit so they can pass nicely into our
48             ## eval.
49 0         0 my $arguments = join( ",", @{ ${ "$self\::EXPORT_CLUSTER" }{ $_ } } );
  0         0  
  0         0  
50            
51             ## The magic happens here ... we require the package we are
52             ## wanting to 'use', change our calling space and import
53             ## the symbols into that calling space.
54 0         0 eval "require $_; package $caller; $_->import( $arguments );";
55              
56             ## If we have an error, go ahead and display it.
57 0 0       0 die( @_ ) if ( @_ );
58             }
59            
60 1         8 return;
61             }
62              
63             ##==================================================================##
64             ## End of Code ##
65             ##==================================================================##
66             1;
67              
68             ##==================================================================##
69             ## Plain Old Documentation (POD) ##
70             ##==================================================================##
71              
72             __END__