| 1 | package Regexp::RegGrp::Data; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use 5.008009; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use Carp; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||
| 8 | 4 | our @ACCESSORS = ( 'regexp', 'replacement', 'store', 'restore_pattern' ); | |||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | ########################################################################################## | ||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | { | ||||||||||||||||||||||||||||||||
| 13 | 4 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||
| 15 | 4 | foreach my $field ( @ACCESSORS ) { | |||||||||||||||||||||||||||||||
| 16 | 16 | ▶ | next if defined *{'Regexp::RegGrp::Data::' . $field}{CODE}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||
| 18 | 16 | *{'Regexp::RegGrp::Data::' . $field} = sub { | |||||||||||||||||||||||||||||||
| 19 | 428 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||
| 21 | 428 | return $self->{'_' . $field}; | |||||||||||||||||||||||||||||||
| 22 | 16 | }; | |||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||
| 26 | sub new { | ||||||||||||||||||||||||||||||||
| 27 | 68 | ▶ | my ( $class, $in_ref ) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=18 SCAR=28.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 28 | 68 | my $self = {}; | |||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||
| 30 | 68 | bless( $self, $class ); | |||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||
| 32 | 68 | ▶ | unless ( $in_ref->{regexp} ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 33 | 2 | carp( 'Value for key "regexp" must be a scalar or a regexp object!' ); | |||||||||||||||||||||||||||||||
| 34 | 2 | return; | |||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||
| 37 | 66 | foreach my $accessor ( @ACCESSORS ) { | |||||||||||||||||||||||||||||||
| 38 | 252 | ▶ | if ( $accessor eq 'regexp' || $accessor eq 'restore_pattern' ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$accessor eq "regexp" or $accessor eq "restore_pattern"
MC/DC100%2/2
$accessor eq "regexp" or $accessor eq "restore_pattern"
$accessor eq "regexp"
$accessor eq "restore_pattern"
Truth table100%3/3
A or B
A= $accessor eq "regexp"B= $accessor eq "restore_pattern"
| |||||||||||||||||||||||||||||||||
| 39 | 126 | ▶ | if ( | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $in_ref->{$accessor} and ref $in_ref->{$accessor} ne "Regexp"
MC/DC100%2/2
ref $in_ref->{$accessor} and ref $in_ref->{$accessor} ne "Regexp"
ref $in_ref->{$accessor}
ref $in_ref->{$accessor} ne "Regexp"
Truth table100%3/3
A and B
A= ref $in_ref->{$accessor}B= ref $in_ref->{$accessor} ne "Regexp"
| |||||||||||||||||||||||||||||||||
| 40 | ref( $in_ref->{$accessor} ) and | ||||||||||||||||||||||||||||||||
| 41 | ref( $in_ref->{$accessor} ) ne 'Regexp' | ||||||||||||||||||||||||||||||||
| 42 | ) { | ||||||||||||||||||||||||||||||||
| 43 | 4 | carp( 'Value for key "' . $accessor . '" must be a scalar or a regexp object!' ); | |||||||||||||||||||||||||||||||
| 44 | 4 | return; | |||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||||||
| 47 | ▶ | elsif ( $accessor eq 'replacement' || $accessor eq 'store' ) { | |||||||||||||||||||||||||||||||
|
Condition66%2/3
$accessor eq "replacement" or $accessor eq "store"
MC/DC0%0/2
$accessor eq "replacement" or $accessor eq "store"
$accessor eq "replacement"
$accessor eq "store"
Truth table66%2/3
A or B
A= $accessor eq "replacement"B= $accessor eq "store"
| |||||||||||||||||||||||||||||||||
| 48 | 126 | ▶ | if ( | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
ref $in_ref->{$accessor} and ref $in_ref->{$accessor} ne "CODE"
MC/DC100%2/2
ref $in_ref->{$accessor} and ref $in_ref->{$accessor} ne "CODE"
ref $in_ref->{$accessor}
ref $in_ref->{$accessor} ne "CODE"
Truth table100%3/3
A and B
A= ref $in_ref->{$accessor}B= ref $in_ref->{$accessor} ne "CODE"
| |||||||||||||||||||||||||||||||||
| 49 | ref( $in_ref->{$accessor} ) and | ||||||||||||||||||||||||||||||||
| 50 | ref( $in_ref->{$accessor} ) ne 'CODE' | ||||||||||||||||||||||||||||||||
| 51 | ) { | ||||||||||||||||||||||||||||||||
| 52 | 4 | carp( 'Value for key "' . $accessor . '" must be a scalar or a code reference!' ); | |||||||||||||||||||||||||||||||
| 53 | 4 | return; | |||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||
| 58 | 58 | ▶ | if ( ref( $in_ref->{modifier} ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 59 | 2 | carp( 'Value for key "modifier" must be a scalar!' ); | |||||||||||||||||||||||||||||||
| 60 | 2 | return; | |||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||
| 63 | 56 | $self->{_regexp} = $in_ref->{regexp}; | |||||||||||||||||||||||||||||||
| 64 | $self->{_replacement} = defined( $in_ref->{store} ) ? ( | ||||||||||||||||||||||||||||||||
| 65 | $in_ref->{restore_pattern} ? $in_ref->{replacement} : sub { | ||||||||||||||||||||||||||||||||
| 66 | 9 | ▶ | return sprintf( "\x01%d\x01", $_[0]->{store_index} ); | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||
| 68 | 56 | ▶ | ) : $in_ref->{replacement}; | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 69 | 56 | $self->{_store} = $in_ref->{store}; | |||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||
| 71 | 56 | ▶ | if ( defined( $in_ref->{modifier} ) || ! ref( $in_ref->{regexp} ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $in_ref->{"modifier"} or not ref $in_ref->{"regexp"}
MC/DC100%2/2
defined $in_ref->{"modifier"} or not ref $in_ref->{"regexp"}
defined $in_ref->{"modifier"}
not ref $in_ref->{"regexp"}
Truth table100%3/3
A or not(B)
A= defined $in_ref->{"modifier"}B= not ref $in_ref->{"regexp"}
| |||||||||||||||||||||||||||||||||
| 72 | 25 | ▶ | my $modifier = defined( $in_ref->{modifier} ) ? $in_ref->{modifier} : 'sm'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||
| 74 | 25 | $self->{_regexp} =~ s/^\(\?[\^dlupimsx-]+:(.*)\)$/$1/si; | |||||||||||||||||||||||||||||||
| 75 | 25 | $self->{_regexp} = sprintf( '(?%s:%s)', $modifier, $self->{_regexp} ); | |||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||
| 78 | 56 | ▶ | my $restore_pattern = $in_ref->{restore_pattern} || qr~\x01(\d+)\x01~; | ||||||||||||||||||||||||||||||
|
Condition66%2/3
$in_ref->{'restore_pattern'} || qr/\x01(\d+)\x01/
MC/DC0%0/2
$in_ref->{'restore_pattern'} || qr/\x01(\d+)\x01/
$in_ref->{'restore_pattern'}
qr/\x01(\d+)\x01/
Truth table66%2/3
A || B
A= $in_ref->{'restore_pattern'}B= qr/\x01(\d+)\x01/
| |||||||||||||||||||||||||||||||||
| 79 | 56 | $self->{_restore_pattern} = qr/$restore_pattern/; | |||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||
| 81 | 56 | return $self; | |||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||
| 84 | 4 | 1; | |||||||||||||||||||||||||||||||