| 1 | package String::Indent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use 5.010001; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | our $DATE = '2024-01-25'; # DATE | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | our $DIST = 'String-Indent'; # DIST | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 2 | our $VERSION = '0.040'; # VERSION | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use Exporter qw(import); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | our @EXPORT_OK = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | indent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 6 | ▶ | sub indent { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
indent: called CC=12 SCAR=25.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 6 | my ($indent, $str, $opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 6 | ▶ | $opts //= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opts //= {}
MC/DC100%1/1
$opts //= {}
$opts
Truth table100%2/2
A
A= $opts
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 6 | ▶ | my $ibl = $opts->{indent_blank_lines} // 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opts->{"indent_blank_lines"} // 1
MC/DC100%1/1
$opts->{"indent_blank_lines"} // 1
$opts->{"indent_blank_lines"}
Truth table100%2/2
A
A= $opts->{"indent_blank_lines"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 6 | ▶ | my $fli = $opts->{first_line_indent} // $indent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$opts->{"first_line_indent"} // $indent
MC/DC0%0/2
$opts->{"first_line_indent"} // $indent
$opts->{"first_line_indent"}
$indent
Truth table66%2/3
A // B
A= $opts->{"first_line_indent"}B= $indent
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 6 | ▶ | my $sli = $opts->{subsequent_lines_indent} // $indent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$opts->{"subsequent_lines_indent"} // $indent
MC/DC0%0/2
$opts->{"subsequent_lines_indent"} // $indent
$opts->{"subsequent_lines_indent"}
$indent
Truth table66%2/3
A // B
A= $opts->{"subsequent_lines_indent"}B= $indent
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 6 | ▶ | my $flopi = $opts->{first_line_of_para_indent} // $sli // $indent; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
($opts->{"first_line_of_para_indent"} // $sli) // $indent
$opts->{"first_line_of_para_indent"} // $sli
MC/DC0%0/3
($opts->{"first_line_of_para_indent"} // $sli) // $indent
$opts->{"first_line_of_para_indent"}
$sli
$indent
Truth table50%2/4
A // B // C
A= $opts->{"first_line_of_para_indent"}B= $sliC= $indent
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | #say "D:ibl=<$ibl>, fli=<$fli>, flopi=<$flopi>, sli=<$sli>"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 6 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 6 | my $prev_blank; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 6 | ▶ | $str =~ s/^([^\r\n]?)/$i++; my $blank = !$1; my $start_para = $i==1 || $prev_blank; $prev_blank = $blank; !$ibl && $blank ? "$1" : $i==1 ? "$fli$1" : $start_para ? "$flopi$1" : "$sli$1"/egm; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%6/6
$i == 1 || $prev_blank
not $ibl and $blank
MC/DC100%2/2
$i == 1 || $prev_blank
$i == 1
$prev_blank
MC/DC100%2/2
not $ibl and $blank
not $ibl
$blank
Truth table100%3/3
A || B
A= $i == 1B= $prev_blank
Truth table100%3/3
not(A) and B
A= not $iblB= $blank
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 6 | $str; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # ABSTRACT: String indenting routines | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||