lib/App/perlmv/scriptlet/remove_common_prefix.pm

filter: Statementstmt 100% 26 / 26 Branchbran 83.3% 5 / 6 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 92.8% 39 / 42 CC 5 SCAR 11.7
CC
5
Cov
94%
__ANON__
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.2
« lib/App/perlmv/scriptlet/remove_common_suffix.pm ↑ Summary blib/lib/Complete/App/perlmv.pm »
1 package App::perlmv::scriptlet::remove_common_prefix;
2  
3 6 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 6 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
8 6 our $DATE = '2026-11-06'; # DATE
9 6 our $DIST = 'App-perlmv'; # DIST
10 6 our $VERSION = '0.610'; # VERSION
11  
12 our $SCRIPTLET = {
13 summary => 'Remove prefix that are common to all args, e.g. (file1, file2b) -> (1, 2b)',
14 18 ▶ code => sub {
Subroutine __ANON__: called CC=5 SCAR=16.1
15 package
16 App::perlmv::code;
17 6 ▶ use vars qw($COMMON_PREFIX $TESTING $FILES);
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 18 ▶ if (!defined($COMMON_PREFIX) && !$TESTING) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $App::perlmv::code::COMMON_PREFIX or $App::perlmv::code::TESTING) 5 13 18
Condition66%2/3
defined $App::perlmv::code::COMMON_PREFIX or $App::perlmv::code::TESTING
l!l&&r!l&&!r
1305
MC/DC50%1/2
defined $App::perlmv::code::COMMON_PREFIX or $App::perlmv::code::TESTING
defined $App::perlmv::code::COMMON_PREFIX $App::perlmv::code::TESTING
Truth table66%2/3
A or B
A= defined $App::perlmv::code::COMMON_PREFIXB= $App::perlmv::code::TESTING
ABresult
1X1
011
000
20 5 my $i;
21 5 ▶ for ($i=0; $i<length($FILES->[0]); $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < length $App::perlmv::code::FILES->[0]) 12 0 12
22 12 ▶ last if grep { substr($_, $i, 1) ne substr($FILES->[0], $i, 1) } @{$FILES}[1..@$FILES-1];
Branch: 1 branch
BranchTrueFalseTotal
if grep {substr($_, $i, 1) ne substr($App::perlmv::code::FILES->[0], $i, 1);} @{$App::perlmv::code::FILES;}[1 .. @$App::perlmv::code::FILES - 1] 5 7 12
23 }
24 5 $COMMON_PREFIX = substr($FILES->[0], 0, $i);
25 }
26  
27 18 s/^\Q$COMMON_PREFIX//;
28 18 $_;
29 },
30 6 };
31  
32 6 1;
33  
34 # ABSTRACT: Remove prefix that are common to all args, e.g. (file1, file2b) -> (1, 2b)
35  
36 __END__
« lib/App/perlmv/scriptlet/remove_common_suffix.pm ↑ Summary blib/lib/Complete/App/perlmv.pm »