line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package String::CommonSuffix; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2014-12-10'; # DATE |
4
|
|
|
|
|
|
|
our $VERSION = '0.01'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
562
|
use 5.010001; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
49
|
|
7
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
8
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use Exporter; |
|
1
|
|
|
|
|
16
|
|
|
1
|
|
|
|
|
259
|
|
11
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
13
|
|
|
|
|
|
|
common_suffix |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub common_suffix { |
17
|
6
|
|
|
6
|
1
|
1261
|
require List::Util; |
18
|
|
|
|
|
|
|
|
19
|
6
|
50
|
|
|
|
15
|
return undef unless @_; |
20
|
6
|
|
|
|
|
7
|
my $i; |
21
|
|
|
|
|
|
|
L1: |
22
|
6
|
|
|
|
|
16
|
for ($i = 0; $i < length($_[0]); $i++) { |
23
|
6
|
|
|
|
|
16
|
for (@_[1..$#_]) { |
24
|
9
|
50
|
|
|
|
16
|
if (length($_) < $i) { |
25
|
0
|
|
|
|
|
0
|
$i--; last L1; |
|
0
|
|
|
|
|
0
|
|
26
|
|
|
|
|
|
|
} else { |
27
|
9
|
100
|
|
|
|
35
|
last L1 if substr($_, -($i+1), 1) ne substr($_[0], -($i+1), 1); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
6
|
100
|
|
|
|
30
|
$i ? substr($_[0], -$i) : ""; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |
35
|
|
|
|
|
|
|
# ABSTRACT: Return suffix common to all strings |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
__END__ |