File Coverage

blib/lib/Sub/Exporter/Lexical.pm
Criterion Covered Total %
statement 25 27 92.5
branch 1 2 50.0
condition 2 3 66.6
subroutine 7 7 100.0
pod 1 1 100.0
total 36 40 90.0


line stmt bran cond sub pod time code
1 1     1   113844 use strict;
  1         3  
  1         39  
2 1     1   5 use warnings;
  1         2  
  1         61  
3             package Sub::Exporter::Lexical;
4             {
5             $Sub::Exporter::Lexical::VERSION = '0.092292';
6             }
7             # ABSTRACT: to export lexically-available subs with Sub::Exporter
8              
9 1     1   14 use v5.12.0;
  1         3  
  1         39  
10              
11 1     1   806 use Lexical::Sub ();
  1         26544  
  1         56  
12              
13 1         13 use Sub::Exporter -setup => {
14             exports => [ qw(lexical_installer) ],
15 1     1   852 };
  1         4  
16              
17              
18             sub lexical_installer {
19             sub {
20 1     1   7476 my ($arg, $to_export) = @_;
21              
22 1         5 my $into = $arg->{into};
23              
24 1         7 my @names =
25 2   66     19 map { $to_export->[ $_ ] }
26 1         5 grep { not($_ % 2) and ! ref $to_export->[$_] } (0 .. $#$to_export);
27              
28 1         4 my @pairs = @$to_export;
29 1         9 while (my ($name, $code) = splice @pairs, 0, 2) {
30 1 50       8 if (ref $name) {
31             # We could implement this easily, but haven't. -- rjbs, 2013-11-24
32 0         0 Carp::cluck("can't import to variable with lexical installer (yet)");
33 0         0 next;
34             }
35 1         4989 Lexical::Sub->import($name, $code);
36             }
37 1     1 1 230 };
38             }
39              
40             1;
41              
42             __END__