| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Regexp::RegGrp::Data; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
29904
|
use 5.008009; |
|
|
4
|
|
|
|
|
19
|
|
|
|
4
|
|
|
|
|
175
|
|
|
4
|
4
|
|
|
4
|
|
26
|
use warnings; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
143
|
|
|
5
|
4
|
|
|
4
|
|
26
|
use strict; |
|
|
4
|
|
|
|
|
14
|
|
|
|
4
|
|
|
|
|
201
|
|
|
6
|
4
|
|
|
4
|
|
24
|
use Carp; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
513
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our @ACCESSORS = ( 'regexp', 'replacement', 'store', 'restore_pattern' ); |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
########################################################################################## |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
{ |
|
13
|
4
|
|
|
4
|
|
22
|
no strict 'refs'; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
2490
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
foreach my $field ( @ACCESSORS ) { |
|
16
|
|
|
|
|
|
|
next if defined *{'Regexp::RegGrp::Data::' . $field}{CODE}; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
*{'Regexp::RegGrp::Data::' . $field} = sub { |
|
19
|
428
|
|
|
428
|
|
6679
|
my $self = shift; |
|
20
|
|
|
|
|
|
|
|
|
21
|
428
|
|
|
|
|
2603
|
return $self->{'_' . $field}; |
|
22
|
|
|
|
|
|
|
}; |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new { |
|
27
|
68
|
|
|
68
|
0
|
11675
|
my ( $class, $in_ref ) = @_; |
|
28
|
68
|
|
|
|
|
113
|
my $self = {}; |
|
29
|
|
|
|
|
|
|
|
|
30
|
68
|
|
|
|
|
170
|
bless( $self, $class ); |
|
31
|
|
|
|
|
|
|
|
|
32
|
68
|
100
|
|
|
|
196
|
unless ( $in_ref->{regexp} ) { |
|
33
|
2
|
|
|
|
|
346
|
carp( 'Value for key "regexp" must be a scalar or a regexp object!' ); |
|
34
|
2
|
|
|
|
|
48
|
return; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
66
|
|
|
|
|
123
|
foreach my $accessor ( @ACCESSORS ) { |
|
38
|
252
|
100
|
100
|
|
|
1346
|
if ( $accessor eq 'regexp' || $accessor eq 'restore_pattern' ) { |
|
|
|
50
|
66
|
|
|
|
|
|
39
|
126
|
100
|
100
|
|
|
1088
|
if ( |
|
40
|
|
|
|
|
|
|
ref( $in_ref->{$accessor} ) and |
|
41
|
|
|
|
|
|
|
ref( $in_ref->{$accessor} ) ne 'Regexp' |
|
42
|
|
|
|
|
|
|
) { |
|
43
|
4
|
|
|
|
|
480
|
carp( 'Value for key "' . $accessor . '" must be a scalar or a regexp object!' ); |
|
44
|
4
|
|
|
|
|
165
|
return; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
elsif ( $accessor eq 'replacement' || $accessor eq 'store' ) { |
|
48
|
126
|
100
|
100
|
|
|
497
|
if ( |
|
49
|
|
|
|
|
|
|
ref( $in_ref->{$accessor} ) and |
|
50
|
|
|
|
|
|
|
ref( $in_ref->{$accessor} ) ne 'CODE' |
|
51
|
|
|
|
|
|
|
) { |
|
52
|
4
|
|
|
|
|
555
|
carp( 'Value for key "' . $accessor . '" must be a scalar or a code reference!' ); |
|
53
|
4
|
|
|
|
|
181
|
return; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
58
|
100
|
|
|
|
170
|
if ( ref( $in_ref->{modifier} ) ) { |
|
59
|
2
|
|
|
|
|
250
|
carp( 'Value for key "modifier" must be a scalar!' ); |
|
60
|
2
|
|
|
|
|
87
|
return; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
56
|
|
|
|
|
158
|
$self->{_regexp} = $in_ref->{regexp}; |
|
64
|
|
|
|
|
|
|
$self->{_replacement} = defined( $in_ref->{store} ) ? ( |
|
65
|
|
|
|
|
|
|
$in_ref->{restore_pattern} ? $in_ref->{replacement} : sub { |
|
66
|
9
|
|
|
9
|
|
50
|
return sprintf( "\x01%d\x01", $_[0]->{store_index} ); |
|
67
|
|
|
|
|
|
|
} |
|
68
|
56
|
100
|
|
|
|
255
|
) : $in_ref->{replacement}; |
|
|
|
100
|
|
|
|
|
|
|
69
|
56
|
|
|
|
|
101
|
$self->{_store} = $in_ref->{store}; |
|
70
|
|
|
|
|
|
|
|
|
71
|
56
|
100
|
100
|
|
|
266
|
if ( defined( $in_ref->{modifier} ) || ! ref( $in_ref->{regexp} ) ) { |
|
72
|
25
|
100
|
|
|
|
73
|
my $modifier = defined( $in_ref->{modifier} ) ? $in_ref->{modifier} : 'sm'; |
|
73
|
|
|
|
|
|
|
|
|
74
|
25
|
|
|
|
|
62
|
$self->{_regexp} =~ s/^\(\?[\^dlupimsx-]+:(.*)\)$/$1/si; |
|
75
|
25
|
|
|
|
|
107
|
$self->{_regexp} = sprintf( '(?%s:%s)', $modifier, $self->{_regexp} ); |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
56
|
|
66
|
|
|
307
|
my $restore_pattern = $in_ref->{restore_pattern} || qr~\x01(\d+)\x01~; |
|
79
|
56
|
|
|
|
|
289
|
$self->{_restore_pattern} = qr/$restore_pattern/; |
|
80
|
|
|
|
|
|
|
|
|
81
|
56
|
|
|
|
|
283
|
return $self; |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |