File Coverage

blib/lib/Array/Contains.pm
Criterion Covered Total %
statement 32 32 100.0
branch 1 2 50.0
condition n/a
subroutine 8 8 100.0
pod n/a
total 41 42 97.6


line stmt bran cond sub pod time code
1             package Array::Contains;
2              
3 3     3   329523 use 5.010_001;
  3         17  
4 3     3   30 use strict;
  3         7  
  3         200  
5 3     3   26 use warnings;
  3         24  
  3         246  
6 3     3   20 use mro 'c3';
  3         8  
  3         23  
7 3     3   2034 use English;
  3         10032  
  3         17  
8             our $VERSION = 3.1;
9 3     3   1437 use Carp;
  3         7  
  3         589  
10              
11             require Exporter;
12              
13             our @ISA = qw(Exporter);
14              
15             our @EXPORT = qw(contains);
16              
17             BEGIN {
18             # Check perl version and decide which version of the function we are going to load.
19 3     3   12 my $perlversion = $];
20 3         15 my $basemodule = 'Array::Contains::Legacy';
21 3 50       15 if($perlversion >= 5.042) {
22 3         5 $basemodule = 'Array::Contains::Any';
23             }
24             #print STDERR $basemodule, "\n";
25              
26             # Import the module. require() uses a filename, not a package name.
27 3         6 my $fname = $basemodule . '.pm';
28 3         15 $fname =~ s/\:\:/\//g;
29 3         1372 require $fname;
30 3         101 $basemodule->import();
31              
32             {
33             # make the contains() function in our package point to the _contains function of the sub-package
34 3     3   21 no strict 'refs'; ## no critic (TestingAndDebugging::ProhibitNoStrict)
  3         4  
  3         275  
  3         6  
35 3         8 my $funcname = $basemodule . '::_contains';
36 3         8 *{__PACKAGE__ . "::contains"} = \&$funcname;
  3         154  
37             }
38             };
39              
40             1;
41             __END__