line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# Copyright (C) 1999 Eric Bohlman, Loic Dachary |
3
|
|
|
|
|
|
|
# Copyright (C) 2013 Jon Jensen |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify it |
6
|
|
|
|
|
|
|
# under the terms of the GNU General Public License as published by the |
7
|
|
|
|
|
|
|
# Free Software Foundation; either version 2, or (at your option) any |
8
|
|
|
|
|
|
|
# later version. You may also use, redistribute and/or modify it |
9
|
|
|
|
|
|
|
# under the terms of the Artistic License supplied with your Perl |
10
|
|
|
|
|
|
|
# distribution |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, |
13
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
|
|
|
|
# GNU General Public License for more details. |
16
|
|
|
|
|
|
|
# |
17
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License |
18
|
|
|
|
|
|
|
# along with this program; if not, write to the Free Software |
19
|
|
|
|
|
|
|
# Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
package Text::Query::SolveSimpleString; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
BEGIN { |
24
|
2
|
|
|
2
|
|
96
|
require 5.005; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
2
|
|
|
2
|
|
9
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
62
|
|
28
|
|
|
|
|
|
|
|
29
|
2
|
|
|
2
|
|
879
|
use Text::Query::Solve; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
76
|
|
30
|
|
|
|
|
|
|
|
31
|
2
|
|
|
2
|
|
11
|
use vars qw(@ISA); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
781
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
@ISA = qw(Text::Query::Solve); |
34
|
|
|
|
|
|
|
|
35
|
4
|
|
|
4
|
0
|
9
|
sub initialize { |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub match { |
39
|
20
|
|
|
20
|
1
|
31
|
my($self) = shift; |
40
|
20
|
|
|
|
|
23
|
my($expr) = shift; |
41
|
20
|
100
|
33
|
|
|
138
|
return $self->matchscalar($expr, shift || $_) if(@_ <= 1 && ref($_[0]) ne 'ARRAY'); |
|
|
|
100
|
|
|
|
|
42
|
3
|
100
|
66
|
|
|
16
|
my($pa) = (@_ == 1 && ref($_[0]) eq 'ARRAY') ? shift : \@_; |
43
|
|
|
|
|
|
|
|
44
|
3
|
|
|
|
|
4
|
my(@ra); |
45
|
3
|
100
|
|
|
|
10
|
if(ref($pa->[0]) eq 'ARRAY') { |
46
|
1
|
|
|
|
|
3
|
@ra = map { [ @$_, $self->matchscalar($expr, $_->[0]) ] } @$pa; |
|
4
|
|
|
|
|
12
|
|
47
|
|
|
|
|
|
|
} else { |
48
|
2
|
|
|
|
|
4
|
@ra = map { [ $_, $self->matchscalar($expr, $_) ] } @$pa; |
|
8
|
|
|
|
|
20
|
|
49
|
|
|
|
|
|
|
} |
50
|
3
|
|
|
|
|
13
|
@ra = sort { $b->[-1] <=> $a->[-1] } @ra; |
|
12
|
|
|
|
|
23
|
|
51
|
3
|
50
|
|
|
|
21
|
return wantarray ? @ra : \@ra; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub matchscalar { |
55
|
31
|
|
|
31
|
1
|
50
|
my($self) = shift; |
56
|
31
|
|
|
|
|
34
|
my($expr) = shift; |
57
|
|
|
|
|
|
|
|
58
|
31
|
|
66
|
|
|
73
|
my($target) = (shift || $_); |
59
|
31
|
|
|
|
|
33
|
my($cnt) = 0; |
60
|
31
|
|
|
|
|
43
|
my($re, $ws) = @$expr; |
61
|
|
|
|
|
|
|
|
62
|
31
|
|
|
|
|
1010
|
while($target =~ /$re/g) { |
63
|
31
|
100
|
|
|
|
95
|
return 0 if(!$^R->[0]); |
64
|
29
|
|
|
|
|
43
|
$cnt += $^R->[1]; |
65
|
29
|
|
|
|
|
332
|
$ws &= $^R->[0]; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
29
|
100
|
|
|
|
202
|
return $ws ? 0 : $cnt; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__END__ |