Data/Unixish/lins.pm

filter: Statementstmt 100% 30 / 30 Branchbran 100% 4 / 4 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 7 / 7 Podpod 100% 1 / 1 totaltotal 95.7% 45 / 47 CC 4 SCAR 5.9
CC
4
Cov
97%
_lins_item
3.0
lins
2.0
BEGIN
1.0
CRAP 1.8
« Data/Unixish/lcfirst.pm ↑ Summary Data/Unixish/rins.pm »
1 package Data::Unixish::lins;
2  
3 2 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use syntax 'each_on_array'; # to support perl < 5.12
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 #use Log::Any '$log';
8  
9 2 ▶use Data::Unixish::Util qw(%common_args);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
12 2 our $DATE = '2025-02-24'; # DATE
13 2 our $DIST = 'Data-Unixish'; # DIST
14 2 our $VERSION = '1.574'; # VERSION
15  
16 2 our %SPEC;
17  
18 $SPEC{lins} = {
19 2 v => 1.1,
20 summary => 'Add some text at the beginning of each line of text',
21 description => <<'MARKDOWN',
22  
23 This is sort of a counterpart for ltrim, which removes whitespace at the
24 beginning (left) of each line of text.
25  
26 MARKDOWN
27 args => {
28 %common_args,
29 text => {
30 summary => 'The text to add',
31 schema => ['str*'],
32 req => 1,
33 pos => 0,
34 },
35 },
36 tags => [qw/text itemfunc/],
37 };
38 1 ▶sub lins {
Subroutine lins: called CC=2 SCAR=6.9
Pod documented
39 1 my %args = @_;
40 1 my ($in, $out) = ($args{in}, $args{out});
41  
42 1 ▶ while (my ($index, $item) = each @$in) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each @$in) 4 1 5
43 4 push @$out, _lins_item($item, \%args);
44 }
45  
46 1 [200, "OK"];
47 }
48  
49 8 ▶sub _lins_item {
Subroutine _lins_item: called CC=3 SCAR=11.0
50 8 my ($item, $args) = @_;
51  
52 8 ▶ if (defined($item) && !ref($item)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $item and not ref $item) 6 2 8
Condition66%2/3
defined $item and not ref $item
!ll&&!rl&&r
026
MC/DC50%1/2
defined $item and not ref $item
defined $item not ref $item
Truth table66%2/3
A and not(B)
A= defined $itemB= not ref $item
ABresult
0X0
100
111
53 6 $item =~ s/^/$args->{text}/mg;
54 }
55 8 return $item;
56 }
57  
58 2 1;
59 # ABSTRACT: Add some text at the beginning of each line of text
60  
61 __END__
« Data/Unixish/lcfirst.pm ↑ Summary Data/Unixish/rins.pm »