line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::Unixish::lins; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
394
|
use 5.010; |
|
1
|
|
|
|
|
6
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
5
|
1
|
|
|
1
|
|
326
|
use syntax 'each_on_array'; # to support perl < 5.12 |
|
1
|
|
|
|
|
19071
|
|
|
1
|
|
|
|
|
4
|
|
6
|
1
|
|
|
1
|
|
2812
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
7
|
|
|
|
|
|
|
#use Log::Any '$log'; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
371
|
use Data::Unixish::Util qw(%common_args); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
271
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.570'; # VERSION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our %SPEC; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
$SPEC{lins} = { |
16
|
|
|
|
|
|
|
v => 1.1, |
17
|
|
|
|
|
|
|
summary => 'Add some text at the beginning of each line of text', |
18
|
|
|
|
|
|
|
description => <<'_', |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
This is sort of a counterpart for ltrim, which removes whitespace at the |
21
|
|
|
|
|
|
|
beginning (left) of each line of text. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
_ |
24
|
|
|
|
|
|
|
args => { |
25
|
|
|
|
|
|
|
%common_args, |
26
|
|
|
|
|
|
|
text => { |
27
|
|
|
|
|
|
|
summary => 'The text to add', |
28
|
|
|
|
|
|
|
schema => ['str*'], |
29
|
|
|
|
|
|
|
req => 1, |
30
|
|
|
|
|
|
|
pos => 0, |
31
|
|
|
|
|
|
|
}, |
32
|
|
|
|
|
|
|
}, |
33
|
|
|
|
|
|
|
tags => [qw/text itemfunc/], |
34
|
|
|
|
|
|
|
}; |
35
|
|
|
|
|
|
|
sub lins { |
36
|
1
|
|
|
1
|
1
|
3
|
my %args = @_; |
37
|
1
|
|
|
|
|
3
|
my ($in, $out) = ($args{in}, $args{out}); |
38
|
|
|
|
|
|
|
|
39
|
1
|
|
|
|
|
6
|
while (my ($index, $item) = each @$in) { |
40
|
4
|
|
|
|
|
15
|
push @$out, _lins_item($item, \%args); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
1
|
|
|
|
|
4
|
[200, "OK"]; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _lins_item { |
47
|
8
|
|
|
8
|
|
12
|
my ($item, $args) = @_; |
48
|
|
|
|
|
|
|
|
49
|
8
|
100
|
66
|
|
|
31
|
if (defined($item) && !ref($item)) { |
50
|
6
|
|
|
|
|
26
|
$item =~ s/^/$args->{text}/mg; |
51
|
|
|
|
|
|
|
} |
52
|
8
|
|
|
|
|
26
|
return $item; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
# ABSTRACT: Add some text at the beginning of each line of text |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__END__ |