File Coverage

blib/lib/Data/Sah/Filter/perl/Str/ltrim.pm
Criterion Covered Total %
statement 8 14 57.1
branch n/a
condition n/a
subroutine 3 5 60.0
pod 0 2 0.0
total 11 21 52.3


line stmt bran cond sub pod time code
1             package Data::Sah::Filter::perl::Str::ltrim;
2              
3 1     1   569739 use 5.010001;
  1         5  
4 1     1   8 use strict;
  1         3  
  1         34  
5 1     1   6 use warnings;
  1         7  
  1         323  
6              
7             our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
8             our $DATE = '2024-07-17'; # DATE
9             our $DIST = 'Data-Sah-Filter'; # DIST
10             our $VERSION = '0.025'; # VERSION
11              
12             sub meta {
13             +{
14 0     0 0   v => 1,
15             summary => 'Trim whitespaces at the beginning of string',
16             description => <<'_',
17              
18             Leading tabs and newlines will also be trimmed.
19              
20             _
21             examples => [
22             {value=>'foo'},
23             {value=>' foo ', filtered_value=>'foo '},
24             {value=>" \t \nfoo ", filtered_value=>'foo ', summary=>"Leading tabs and newlines will also be trimmed"},
25             ],
26             };
27             }
28              
29             sub filter {
30 0     0 0   my %args = @_;
31              
32 0           my $dt = $args{data_term};
33              
34 0           my $res = {};
35 0           $res->{expr_filter} = join(
36             "",
37             "do { my \$res = $dt; \$res =~ s/\\A\\s+//s; \$res }",
38             );
39              
40 0           $res;
41             }
42              
43             1;
44             # ABSTRACT: Trim whitespaces at the beginning of string
45              
46             __END__