line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Util; |
2
|
1
|
|
|
1
|
|
513
|
use 5.008001; |
|
1
|
|
|
|
|
2
|
|
3
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
18
|
|
4
|
1
|
|
|
1
|
|
8
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
40
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "0.02"; |
7
|
1
|
|
|
1
|
|
9
|
use vars qw/@ISA @EXPORT @EXPORT_OK/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
219
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
require Exporter; |
10
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
11
|
|
|
|
|
|
|
@EXPORT = @EXPORT_OK = qw/clean_text merge_space/; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub clean_text { |
14
|
0
|
|
|
0
|
0
|
|
my $str = shift; |
15
|
0
|
0
|
|
|
|
|
return unless $str; |
16
|
0
|
|
|
|
|
|
return chompf( merge_space($str) ); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub merge_space { |
20
|
0
|
|
|
0
|
0
|
|
my $str = shift; |
21
|
0
|
0
|
|
|
|
|
return '' unless $str; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
$str =~ s/\t+/ /g; |
24
|
0
|
|
|
|
|
|
$str =~ s/\r\n//g; |
25
|
0
|
|
|
|
|
|
$str =~ s/\s+/ /g; |
26
|
0
|
|
|
|
|
|
return $str; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub chompf { |
30
|
0
|
|
|
0
|
0
|
|
my $str = shift; |
31
|
0
|
0
|
|
|
|
|
return '' unless $str; |
32
|
0
|
|
|
|
|
|
$str =~ s/^\s+//g; |
33
|
0
|
|
|
|
|
|
$str =~ s/\s+$//g; |
34
|
0
|
|
|
|
|
|
return $str; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
__END__ |