| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# ------ Provide anchored SQL wildcards ('^', '$') |
|
2
|
|
|
|
|
|
|
package SQL::AnchoredWildcards; |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ------ use/require pragmas |
|
7
|
1
|
|
|
1
|
|
673
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
35
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
401
|
|
|
9
|
|
|
|
|
|
|
require Exporter; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# ------ define variables |
|
14
|
|
|
|
|
|
|
@ISA = qw(Exporter); # we are an Exporter |
|
15
|
|
|
|
|
|
|
@EXPORT = # we export by default: |
|
16
|
|
|
|
|
|
|
qw(sql_anchor_wildcards); # a function for anchoring SQL wildcards |
|
17
|
|
|
|
|
|
|
@EXPORT_OK = (); # we export nothing upon request |
|
18
|
|
|
|
|
|
|
$VERSION = 1.0; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Preloaded methods go here. |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# ------ enhance SQL wildcard processing by simulating '^' and '$' |
|
27
|
|
|
|
|
|
|
sub sql_anchor_wildcards { |
|
28
|
19
|
|
|
19
|
0
|
503
|
local $_ = shift; # copy of unenhanced searchtext |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# ------ escape SQL '%' and convert to lower case |
|
32
|
19
|
|
|
|
|
46
|
s/%/\%/g; |
|
33
|
19
|
|
|
|
|
37
|
tr/A-Z/a-z/; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# ------ search unanchored at start by user's choice |
|
37
|
19
|
100
|
|
|
|
100
|
if (m/^%/o) { |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
; # do nothing |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# ------ search anchored at start |
|
42
|
|
|
|
|
|
|
} elsif (m/^\^/o) { |
|
43
|
9
|
|
|
|
|
25
|
s/^\^//o; # convert to anchored at start SQL |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# ------ search not anchored at start, but begins with escaped '^' |
|
47
|
|
|
|
|
|
|
} elsif (m/^\\\^/o) { |
|
48
|
4
|
|
|
|
|
11
|
s/^\\//o; # allow escaped '^' |
|
49
|
4
|
|
|
|
|
6
|
$_ = "%" . $_; # convert to unanchored SQL search |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# ------ search not anchored at start |
|
53
|
|
|
|
|
|
|
} else { |
|
54
|
3
|
|
|
|
|
6
|
$_ = "%" . $_; # converted to unanchored SQL search |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# ------ search unanchored at end |
|
59
|
19
|
100
|
|
|
|
80
|
if (m/%$/o) { |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
; # do nothing |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# ------ search not anchored at end, but ends with escaped '$' |
|
64
|
|
|
|
|
|
|
} elsif (m/\\\$$/o) { |
|
65
|
4
|
|
|
|
|
9
|
s/\\\$$/\$/o; # allow escaped '$' |
|
66
|
4
|
|
|
|
|
8
|
$_ .= "%"; # convert to unanchored SQL search |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# ------ search anchored at end |
|
70
|
|
|
|
|
|
|
} elsif (m/\$$/o) { |
|
71
|
9
|
|
|
|
|
22
|
s/\$$//o; # convert to anchored at end SQL search |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# ------ search not anchored at end |
|
75
|
|
|
|
|
|
|
} else { |
|
76
|
3
|
|
|
|
|
4
|
$_ .= "%"; # convert to unanchored SQL search |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# return converted searchtext |
|
80
|
19
|
|
|
|
|
49
|
return $_; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
1; |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# Autoload methods go after =cut, and are processed by the autosplit program. |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |
|
89
|
|
|
|
|
|
|
__END__ |