File Coverage

lib/Perlmazing/Perlmazing/Precompile/truncate_text.pm
Criterion Covered Total %
statement 3 15 20.0
branch 0 10 0.0
condition 0 3 0.0
subroutine 1 2 50.0
pod n/a
total 4 30 13.3


line stmt bran cond sub pod time code
1 32     32   281 use Perlmazing;
  32         95  
  32         194  
2              
3             sub main ($$) {
4 0     0     my ($str, $size) = @_;
5 0 0 0       return '' unless defined $str and length $str;
6 0 0         return unless is_number $size;
7 0           my $length = length $str;
8 0 0         return $str if $length <= $size;
9 0           my $next = substr $str, $size, 1;
10 0           $str = substr $str, 0, $size;
11 0 0         if ((my $index = rindex($str, ' ')) != -1) {
12 0 0         unless ($next eq ' ') {
13 0           $str = substr $str, 0, $index;
14             }
15             }
16 0           $str =~ s/\s+$//;
17 0           $str;
18             }
19              
20             1;