line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Unixish::rtrim; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
457
|
use 5.010; |
|
1
|
|
|
|
|
5
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
5
|
1
|
|
|
1
|
|
330
|
use syntax 'each_on_array'; # to support perl < 5.12 |
|
1
|
|
|
|
|
20296
|
|
|
1
|
|
|
|
|
5
|
|
6
|
1
|
|
|
1
|
|
2869
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
7
|
|
|
|
|
|
|
#use Log::Any '$log'; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
390
|
use Data::Unixish::Util qw(%common_args); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
290
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.570'; # VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our %SPEC; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
$SPEC{rtrim} = { |
16
|
|
|
|
|
|
|
v => 1.1, |
17
|
|
|
|
|
|
|
summary => 'Strip whitespace at the end of each line of text', |
18
|
|
|
|
|
|
|
description => <<'_', |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
_ |
21
|
|
|
|
|
|
|
args => { |
22
|
|
|
|
|
|
|
%common_args, |
23
|
|
|
|
|
|
|
strip_newline => { |
24
|
|
|
|
|
|
|
summary => 'Whether to strip newlines at the end of text', |
25
|
|
|
|
|
|
|
schema =>[bool => {default=>0}], |
26
|
|
|
|
|
|
|
cmdline_aliases => { nl=>{} }, |
27
|
|
|
|
|
|
|
}, |
28
|
|
|
|
|
|
|
}, |
29
|
|
|
|
|
|
|
tags => [qw/text itemfunc/], |
30
|
|
|
|
|
|
|
}; |
31
|
|
|
|
|
|
|
sub rtrim { |
32
|
2
|
|
|
2
|
1
|
7
|
my %args = @_; |
33
|
2
|
|
|
|
|
4
|
my ($in, $out) = ($args{in}, $args{out}); |
34
|
|
|
|
|
|
|
|
35
|
2
|
|
|
|
|
11
|
while (my ($index, $item) = each @$in) { |
36
|
8
|
|
|
|
|
10
|
push @$out, _rtrim_item($item, \%args); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
2
|
|
|
|
|
6
|
[200, "OK"]; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub _rtrim_item { |
43
|
16
|
|
|
16
|
|
34
|
my ($item, $args) = @_; |
44
|
|
|
|
|
|
|
|
45
|
16
|
100
|
66
|
|
|
47
|
if (defined($item) && !ref($item)) { |
46
|
12
|
100
|
|
|
|
30
|
$item =~ s/[\r\n]+\z// if $args->{strip_newline}; |
47
|
12
|
|
|
|
|
37
|
$item =~ s/[ \t]+$//mg; |
48
|
|
|
|
|
|
|
} |
49
|
16
|
|
|
|
|
46
|
return $item; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
# ABSTRACT: Strip whitespace at the end of each line of text |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |