line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::perlmv::scriptlet::remove_common_prefix; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
35
|
use 5.010001; |
|
2
|
|
|
|
|
11
|
|
4
|
2
|
|
|
2
|
|
21
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
45
|
|
5
|
2
|
|
|
2
|
|
37
|
use warnings; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
242
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
8
|
|
|
|
|
|
|
our $DATE = '2023-06-30'; # DATE |
9
|
|
|
|
|
|
|
our $DIST = 'App-perlmv'; # DIST |
10
|
|
|
|
|
|
|
our $VERSION = '0.607'; # VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $SCRIPTLET = { |
13
|
|
|
|
|
|
|
summary => 'Remove prefix that are common to all args, e.g. (file1, file2b) -> (1, 2b)', |
14
|
|
|
|
|
|
|
code => sub { |
15
|
|
|
|
|
|
|
package |
16
|
|
|
|
|
|
|
App::perlmv::code; |
17
|
2
|
|
|
2
|
|
46
|
use vars qw($COMMON_PREFIX $TESTING $FILES); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
546
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
if (!defined($COMMON_PREFIX) && !$TESTING) { |
20
|
|
|
|
|
|
|
my $i; |
21
|
|
|
|
|
|
|
for ($i=0; $i[0]); $i++) { |
22
|
|
|
|
|
|
|
last if grep { substr($_, $i, 1) ne substr($FILES->[0], $i, 1) } @{$FILES}[1..@$FILES-1]; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
$COMMON_PREFIX = substr($FILES->[0], 0, $i); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
s/^\Q$COMMON_PREFIX//; |
28
|
|
|
|
|
|
|
$_; |
29
|
|
|
|
|
|
|
}, |
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
1; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# ABSTRACT: Remove prefix that are common to all args, e.g. (file1, file2b) -> (1, 2b) |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
__END__ |