blib/lib/Exporter/Cluster.pm

filter: Statementstmt 68.7% 11 / 16 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 2 / 2 Podpod n/a totaltotal 65.0% 13 / 20 CC 3 SCAR 13.5
CC
3
Cov
61%
import
4.8
BEGIN
1.0
CRAP 3.8
↑ Summary
1 package Exporter::Cluster;
2 ######################################################################
3 ## ##
4 ## Package: Cluster.pm ##
5 ## Author: D. Hageman <dhageman@dracken.com> ##
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 1 require 5.005; ## This will be the earliest version of Perl we will
19 ## consider supporting with this module.
20  
21 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 1 $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 1 ▶{
Subroutine import: called CC=3 SCAR=15.7
37 1 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 my $caller = caller;
42
43 ## Loop through all of the elements of the EXPORT_CLUSTER hash.
44 1 foreach( keys( %{ "$self\::EXPORT_CLUSTER" } ) )
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 my $arguments = join( ",", @{ ${ "$self\::EXPORT_CLUSTER" }{ $_ } } );
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 eval "require $_; package $caller; $_->import( $arguments );";
55  
56 ## If we have an error, go ahead and display it.
57 0 ▶ die( @_ ) if ( @_ );
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
58 }
59
60 1 return;
61 }
62  
63 ##==================================================================##
64 ## End of Code ##
65 ##==================================================================##
66 1 1;
67  
68 ##==================================================================##
69 ## Plain Old Documentation (POD) ##
70 ##==================================================================##
71  
72 __END__
↑ Summary