File Coverage

blib/lib/String/Indent.pm
Criterion Covered Total %
statement 18 18 100.0
branch 2 2 100.0
condition 4 4 100.0
subroutine 5 5 100.0
pod 1 1 100.0
total 30 30 100.0


line stmt bran cond sub pod time code
1             package String::Indent;
2              
3             our $DATE = '2015-01-03'; # DATE
4             our $VERSION = '0.02'; # VERSION
5              
6 1     1   19685 use 5.010001;
  1         4  
  1         51  
7 1     1   6 use strict;
  1         2  
  1         42  
8 1     1   12 use warnings;
  1         1  
  1         49  
9              
10 1     1   6 use Exporter;
  1         2  
  1         236  
11             our @ISA = qw(Exporter);
12             our @EXPORT_OK = qw(
13             indent
14             );
15              
16             sub indent {
17 2     2 1 13 my ($indent, $str, $opts) = @_;
18 2   100     11 $opts //= {};
19              
20 2 100 100     11 if ($opts->{indent_blank_lines} // 1) {
21 1         10 $str =~ s/^/$indent/mg;
22             } else {
23 1         15 $str =~ s/^([^\r\n]*\S[^\r\n]*)/$indent$1/mg;
24             }
25 2         13 $str;
26             }
27              
28             1;
29             # ABSTRACT: String indenting routines
30              
31             __END__