line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package String::UpdateYears; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
76943
|
use base qw(Exporter); |
|
3
|
|
|
|
|
17
|
|
|
3
|
|
|
|
|
512
|
|
4
|
3
|
|
|
3
|
|
23
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
64
|
|
5
|
3
|
|
|
3
|
|
12
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
99
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
1856
|
use Readonly; |
|
3
|
|
|
|
|
13070
|
|
|
3
|
|
|
|
|
911
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = 0.01; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Constants. |
12
|
|
|
|
|
|
|
Readonly::Array our @EXPORT => qw(update_years); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub update_years { |
15
|
11
|
|
|
11
|
1
|
5684
|
my ($string, $opts_hr, $new_last_year) = @_; |
16
|
|
|
|
|
|
|
|
17
|
11
|
100
|
|
|
|
32
|
if (! defined $opts_hr) { |
18
|
1
|
|
|
|
|
4
|
$opts_hr = {}; |
19
|
|
|
|
|
|
|
} |
20
|
11
|
100
|
|
|
|
27
|
if (! exists $opts_hr->{'prefix_glob'}) { |
21
|
8
|
|
|
|
|
20
|
$opts_hr->{'prefix_glob'} = '.*'; |
22
|
|
|
|
|
|
|
} |
23
|
11
|
100
|
|
|
|
25
|
if (! exists $opts_hr->{'suffix_glob'}) { |
24
|
8
|
|
|
|
|
17
|
$opts_hr->{'suffix_glob'} = '.*'; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
11
|
|
|
|
|
18
|
my $pg = $opts_hr->{'prefix_glob'}; |
28
|
11
|
|
|
|
|
17
|
my $sg = $opts_hr->{'suffix_glob'}; |
29
|
11
|
100
|
|
|
|
276
|
if ($string =~ m/^($pg)(\d{4})-(\d{4})($sg)$/ms) { |
|
|
100
|
|
|
|
|
|
30
|
5
|
|
|
|
|
13
|
my $pre = $1; |
31
|
5
|
|
|
|
|
10
|
my $first_year = $2; |
32
|
5
|
|
|
|
|
8
|
my $last_year = $3; |
33
|
5
|
|
|
|
|
10
|
my $post = $4; |
34
|
5
|
100
|
|
|
|
17
|
if ($last_year != $new_last_year) { |
35
|
4
|
|
|
|
|
24
|
my $new_string = $pre.$first_year.'-'.$new_last_year.$post; |
36
|
4
|
|
|
|
|
33
|
return $new_string; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} elsif ($string =~ m/^($pg)(\d{4})($sg)$/ms) { |
39
|
5
|
|
|
|
|
15
|
my $pre = $1; |
40
|
5
|
|
|
|
|
11
|
my $first_year = $2; |
41
|
5
|
|
|
|
|
12
|
my $post = $3; |
42
|
5
|
100
|
|
|
|
17
|
if ($first_year != $new_last_year) { |
43
|
4
|
|
|
|
|
12
|
my $new_string = $pre.$first_year.'-'.$new_last_year.$post; |
44
|
4
|
|
|
|
|
20
|
return $new_string; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
3
|
|
|
|
|
10
|
return; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |