line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Regexp::RegGrp::Data; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
14567
|
use 5.008009; |
|
4
|
|
|
|
|
10
|
|
4
|
4
|
|
|
4
|
|
17
|
use warnings; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
105
|
|
5
|
4
|
|
|
4
|
|
15
|
use strict; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
80
|
|
6
|
4
|
|
|
4
|
|
14
|
use Carp; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
327
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our @ACCESSORS = ( 'regexp', 'replacement', 'store', 'restore_pattern' ); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
########################################################################################## |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
{ |
13
|
4
|
|
|
4
|
|
17
|
no strict 'refs'; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
1728
|
|
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
|
|
5224
|
my $self = shift; |
20
|
|
|
|
|
|
|
|
21
|
428
|
|
|
|
|
1212
|
return $self->{'_' . $field}; |
22
|
|
|
|
|
|
|
}; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new { |
27
|
68
|
|
|
68
|
0
|
9174
|
my ( $class, $in_ref ) = @_; |
28
|
68
|
|
|
|
|
77
|
my $self = {}; |
29
|
|
|
|
|
|
|
|
30
|
68
|
|
|
|
|
80
|
bless( $self, $class ); |
31
|
|
|
|
|
|
|
|
32
|
68
|
100
|
|
|
|
125
|
unless ( $in_ref->{regexp} ) { |
33
|
2
|
|
|
|
|
350
|
carp( 'Value for key "regexp" must be a scalar or a regexp object!' ); |
34
|
2
|
|
|
|
|
64
|
return; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
66
|
|
|
|
|
92
|
foreach my $accessor ( @ACCESSORS ) { |
38
|
252
|
100
|
100
|
|
|
900
|
if ( $accessor eq 'regexp' || $accessor eq 'restore_pattern' ) { |
|
|
50
|
66
|
|
|
|
|
39
|
126
|
100
|
100
|
|
|
359
|
if ( |
40
|
|
|
|
|
|
|
ref( $in_ref->{$accessor} ) and |
41
|
|
|
|
|
|
|
ref( $in_ref->{$accessor} ) ne 'Regexp' |
42
|
|
|
|
|
|
|
) { |
43
|
4
|
|
|
|
|
439
|
carp( 'Value for key "' . $accessor . '" must be a scalar or a regexp object!' ); |
44
|
4
|
|
|
|
|
216
|
return; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
elsif ( $accessor eq 'replacement' || $accessor eq 'store' ) { |
48
|
126
|
100
|
100
|
|
|
339
|
if ( |
49
|
|
|
|
|
|
|
ref( $in_ref->{$accessor} ) and |
50
|
|
|
|
|
|
|
ref( $in_ref->{$accessor} ) ne 'CODE' |
51
|
|
|
|
|
|
|
) { |
52
|
4
|
|
|
|
|
442
|
carp( 'Value for key "' . $accessor . '" must be a scalar or a code reference!' ); |
53
|
4
|
|
|
|
|
229
|
return; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
58
|
100
|
|
|
|
89
|
if ( ref( $in_ref->{modifier} ) ) { |
59
|
2
|
|
|
|
|
147
|
carp( 'Value for key "modifier" must be a scalar!' ); |
60
|
2
|
|
|
|
|
58
|
return; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
56
|
|
|
|
|
81
|
$self->{_regexp} = $in_ref->{regexp}; |
64
|
|
|
|
|
|
|
$self->{_replacement} = defined( $in_ref->{store} ) ? ( |
65
|
|
|
|
|
|
|
$in_ref->{restore_pattern} ? $in_ref->{replacement} : sub { |
66
|
9
|
|
|
9
|
|
28
|
return sprintf( "\x01%d\x01", $_[0]->{store_index} ); |
67
|
|
|
|
|
|
|
} |
68
|
56
|
100
|
|
|
|
108
|
) : $in_ref->{replacement}; |
|
|
100
|
|
|
|
|
|
69
|
56
|
|
|
|
|
63
|
$self->{_store} = $in_ref->{store}; |
70
|
|
|
|
|
|
|
|
71
|
56
|
100
|
100
|
|
|
176
|
if ( defined( $in_ref->{modifier} ) || ! ref( $in_ref->{regexp} ) ) { |
72
|
25
|
100
|
|
|
|
42
|
my $modifier = defined( $in_ref->{modifier} ) ? $in_ref->{modifier} : 'sm'; |
73
|
|
|
|
|
|
|
|
74
|
25
|
|
|
|
|
42
|
$self->{_regexp} =~ s/^\(\?[\^dlupimsx-]+:(.*)\)$/$1/si; |
75
|
25
|
|
|
|
|
93
|
$self->{_regexp} = sprintf( '(?%s:%s)', $modifier, $self->{_regexp} ); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
56
|
|
66
|
|
|
194
|
my $restore_pattern = $in_ref->{restore_pattern} || qr~\x01(\d+)\x01~; |
79
|
56
|
|
|
|
|
164
|
$self->{_restore_pattern} = qr/$restore_pattern/; |
80
|
|
|
|
|
|
|
|
81
|
56
|
|
|
|
|
127
|
return $self; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |