line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use Catmandu::Sane; |
3
|
1
|
|
|
1
|
|
86226
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
4
|
|
|
|
|
|
|
our $VERSION = '1.2019'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Moo; |
7
|
1
|
|
|
1
|
|
6
|
use Catmandu::Util::Path qw(as_path); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
5
|
|
8
|
1
|
|
|
1
|
|
682
|
use Catmandu::Util::Regex qw(as_regex); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
9
|
1
|
|
|
1
|
|
333
|
use namespace::clean; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
10
|
1
|
|
|
1
|
|
6
|
use Catmandu::Fix::Has; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
11
|
1
|
|
|
1
|
|
610
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
12
|
|
|
|
|
|
|
has path => (fix_arg => 1); |
13
|
|
|
|
|
|
|
has pattern => (fix_arg => 1); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
with 'Catmandu::Fix::Builder'; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my ($self) = @_; |
18
|
|
|
|
|
|
|
my $regex = as_regex($self->pattern); |
19
|
3
|
|
|
3
|
|
28
|
as_path($self->path)->updater( |
20
|
3
|
|
|
|
|
11
|
if_string => sub { |
21
|
|
|
|
|
|
|
my $val = $_[0]; |
22
|
|
|
|
|
|
|
if ($val =~ m/$regex/) { |
23
|
3
|
|
|
3
|
|
7
|
if (@+ < 2) { # no capturing groups |
24
|
3
|
50
|
|
|
|
20
|
return undef, 1, 0; |
25
|
3
|
100
|
|
|
|
24
|
} |
|
|
100
|
|
|
|
|
|
26
|
1
|
|
|
|
|
17
|
elsif (%+) { # named capturing groups |
27
|
|
|
|
|
|
|
return +{%+}; |
28
|
1
|
|
|
1
|
|
793
|
} |
|
1
|
|
|
|
|
319
|
|
|
1
|
|
|
|
|
42
|
|
29
|
1
|
|
|
|
|
30
|
else { # numbered capturing groups |
30
|
|
|
|
|
|
|
no strict 'refs'; |
31
|
|
|
|
|
|
|
return [map {${$_}} 1 .. (@+ - 1)]; |
32
|
1
|
|
|
1
|
|
5
|
} |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
104
|
|
33
|
1
|
|
|
|
|
4
|
} |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
27
|
|
34
|
|
|
|
|
|
|
return undef, 1, 0; |
35
|
|
|
|
|
|
|
} |
36
|
0
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
} |
38
|
3
|
|
|
|
|
16
|
|
39
|
|
|
|
|
|
|
1; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=pod |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 NAME |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Catmandu::Fix::parse_text - parses a text into an array or hash of values |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 SYNOPSIS |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# date: "2015-03-07" |
51
|
|
|
|
|
|
|
parse_text(date, '(\d\d\d\d)-(\d\d)-(\d\d)') |
52
|
|
|
|
|
|
|
# date: |
53
|
|
|
|
|
|
|
# - 2015 |
54
|
|
|
|
|
|
|
# - 03 |
55
|
|
|
|
|
|
|
# - 07 |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# date: "2015-03-07" |
58
|
|
|
|
|
|
|
parse_text(date, '(?<year>\d\d\d\d)-(?<month>\d\d)-(?<day>\d\d)') |
59
|
|
|
|
|
|
|
# date: |
60
|
|
|
|
|
|
|
# year: "2015" |
61
|
|
|
|
|
|
|
# month: "03" |
62
|
|
|
|
|
|
|
# day: "07" |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# date: "abcd" |
65
|
|
|
|
|
|
|
parse_text(date, '(\d\d\d\d)-(\d\d)-(\d\d)') |
66
|
|
|
|
|
|
|
# date: "abcd" |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 SEE ALSO |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
L<Catmandu::Fix> |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
L<Catmandu::Importer::Text> |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |