blib/lib/alias/module.pm

filter: Statementstmt 27.7% 5 / 18 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 1 Podpod n/a totaltotal 18.5% 5 / 27 CC 5 SCAR 34.0
CC
5
Cov
19%
import
30.0
CRAP 30.0
↑ Summary
1 ## no critic: TestingAndDebugging::RequireUseStrict
2 package alias::module;
3  
4 1 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
5 1 our $DATE = '2023-09-30'; # DATE
6 1 our $DIST = 'alias-module'; # DIST
7 1 our $VERSION = '0.003'; # VERSION
8  
9 0 ▶sub import {
Subroutine import: not called CC=5 SCAR=34.0
10 0 my $class = shift;
11 0 ▶ my $noreq = $_[0] eq '-norequire' ? shift : 0;
Branch: 1 branch
BranchTrueFalseTotal
$_[0] eq '-norequire' ? : 0 0 0
12 0 my $orig = shift;
13  
14 0 ▶ defined $orig or die "Please specify package to alias from";
Branch: 1 branch
BranchTrueFalseTotal
defined $orig or die "Please specify package to alias from" 0 0 0
15  
16 0 my $caller = caller();
17  
18 0 ▶ if ($caller eq $orig) {
Branch: 1 branch
BranchTrueFalseTotal
if ($caller eq $orig) 0 0 0
19 0 warn "Aliasing from the same package '$caller', probably a typo?";
20 }
21  
22 0 ▶ unless ($noreq) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($noreq) 0 0 0
23 0 (my $orig_pm = "$orig.pm") =~ s!::!/!g;
24 0 require $orig_pm;
25 }
26 0 *{$caller . "::"} = \*{$orig . "::"};
27 }
28  
29 1 1;
30 # ABSTRACT: Alias one module as another
31  
32 __END__
↑ Summary