| 1 | package Catmandu::Fix::parse_text; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 1 | ▶ | use Catmandu::Sane; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | |||||||||||||||
| 5 | 1 | our $VERSION = '1.2025'; | |||||||||||||
| 6 | |||||||||||||||
| 7 | 1 | ▶ | use Moo; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 8 | 1 | ▶ | use Catmandu::Util::Path qw(as_path); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 9 | 1 | ▶ | use Catmandu::Util::Regex qw(as_regex); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 10 | 1 | ▶ | use namespace::clean; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 11 | 1 | ▶ | use Catmandu::Fix::Has; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 12 | |||||||||||||||
| 13 | 1 | has path => (fix_arg => 1); | |||||||||||||
| 14 | 1 | has pattern => (fix_arg => 1); | |||||||||||||
| 15 | |||||||||||||||
| 16 | 1 | with 'Catmandu::Fix::Builder'; | |||||||||||||
| 17 | |||||||||||||||
| 18 | 3 | ▶ | sub _build_fixer { | ||||||||||||
|
Subroutine
_build_fixer: called CC=1 SCAR=0.0
| |||||||||||||||
| 19 | 3 | my ($self) = @_; | |||||||||||||
| 20 | 3 | my $regex = as_regex($self->pattern); | |||||||||||||
| 21 | as_path($self->path)->updater( | ||||||||||||||
| 22 | 3 | ▶ | if_string => sub { | ||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||
| 23 | 3 | my $val = $_[0]; | |||||||||||||
| 24 | 3 | ▶ | if ($val =~ m/$regex/) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 25 | 3 | ▶ | if (@+ < 2) { # no capturing groups | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 26 | 1 | return undef, 1, 0; | |||||||||||||
| 27 | } | ||||||||||||||
| 28 | elsif (%+) { # named capturing groups | ||||||||||||||
| 29 | 1 | return +{%+}; | |||||||||||||
| 30 | } | ||||||||||||||
| 31 | else { # numbered capturing groups | ||||||||||||||
| 32 | 1 | ▶ | no strict 'refs'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 33 | 1 | return [map {${$_}} 1 .. (@+ - 1)]; | |||||||||||||
| 34 | } | ||||||||||||||
| 35 | } | ||||||||||||||
| 36 | 0 | return undef, 1, 0; | |||||||||||||
| 37 | } | ||||||||||||||
| 38 | 3 | ); | |||||||||||||
| 39 | } | ||||||||||||||
| 40 | |||||||||||||||
| 41 | 1 | 1; | |||||||||||||
| 42 | |||||||||||||||
| 43 | __END__ | ||||||||||||||