line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package String::Trim::More; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2014-12-10'; # DATE |
4
|
|
|
|
|
|
|
our $VERSION = '0.01'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
24689
|
use 5.010001; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
54
|
|
7
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
48
|
|
8
|
1
|
|
|
1
|
|
8
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
75
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
6
|
use Exporter; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
646
|
|
11
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
13
|
|
|
|
|
|
|
ltrim |
14
|
|
|
|
|
|
|
rtrim |
15
|
|
|
|
|
|
|
trim |
16
|
|
|
|
|
|
|
ltrim_lines |
17
|
|
|
|
|
|
|
rtrim_lines |
18
|
|
|
|
|
|
|
trim_lines |
19
|
|
|
|
|
|
|
trim_blank_lines |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub ltrim { |
23
|
6
|
|
|
6
|
1
|
600
|
my $str = shift; |
24
|
6
|
|
|
|
|
16
|
$str =~ s/\A\s+//s; |
25
|
6
|
|
|
|
|
21
|
$str; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub rtrim { |
29
|
6
|
|
|
6
|
1
|
931
|
my $str = shift; |
30
|
6
|
|
|
|
|
21
|
$str =~ s/\s+\z//s; |
31
|
6
|
|
|
|
|
21
|
$str; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub trim { |
35
|
6
|
|
|
6
|
1
|
958
|
my $str = shift; |
36
|
6
|
|
|
|
|
15
|
$str =~ s/\A\s+//s; |
37
|
6
|
|
|
|
|
16
|
$str =~ s/\s+\z//s; |
38
|
6
|
|
|
|
|
18
|
$str; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub ltrim_lines { |
42
|
6
|
|
|
6
|
1
|
1012
|
my $str = shift; |
43
|
6
|
|
|
|
|
22
|
$str =~ s/^[ \t]+//mg; # XXX other unicode non-newline spaces |
44
|
6
|
|
|
|
|
19
|
$str; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub rtrim_lines { |
48
|
6
|
|
|
6
|
1
|
931
|
my $str = shift; |
49
|
6
|
|
|
|
|
21
|
$str =~ s/[ \t]+$//mg; |
50
|
6
|
|
|
|
|
16
|
$str; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub trim_lines { |
54
|
6
|
|
|
6
|
1
|
1066
|
my $str = shift; |
55
|
6
|
|
|
|
|
18
|
$str =~ s/^[ \t]+//mg; |
56
|
6
|
|
|
|
|
12
|
$str =~ s/[ \t]+$//mg; |
57
|
6
|
|
|
|
|
16
|
$str; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub trim_blank_lines { |
61
|
2
|
|
|
2
|
1
|
578
|
local $_ = shift; |
62
|
2
|
100
|
|
|
|
10
|
return $_ unless defined; |
63
|
1
|
|
|
|
|
5
|
s/\A(?:\n\s*)+//; |
64
|
1
|
|
|
|
|
6
|
s/(?:\n\s*){2,}\z/\n/; |
65
|
1
|
|
|
|
|
438
|
$_; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
# ABSTRACT: Various string trimming utilities |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__END__ |