line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Goo::ThingFinder; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
############################################################################### |
4
|
|
|
|
|
|
|
# Nigel Hamilton |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Copyright Nigel Hamilton 2005 |
7
|
|
|
|
|
|
|
# All Rights Reserved |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Author: Nigel Hamilton |
10
|
|
|
|
|
|
|
# Filename: Goo::ThingFinder.pm |
11
|
|
|
|
|
|
|
# Description: Find all the "Things" in a string |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# Date Change |
14
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
15
|
|
|
|
|
|
|
# 01/07/2005 Auto generated file |
16
|
|
|
|
|
|
|
# 01/07/2005 Need to extract all the Things to show in profile |
17
|
|
|
|
|
|
|
# 01/08/2005 Added the ability to show an indexed table of things |
18
|
|
|
|
|
|
|
# Replace OO interface with simple package |
19
|
|
|
|
|
|
|
# |
20
|
|
|
|
|
|
|
############################################################################### |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
520
|
use Goo::TypeManager; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
26
|
|
25
|
1
|
|
|
1
|
|
7
|
use Text::FormatTable; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
481
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
############################################################################### |
29
|
|
|
|
|
|
|
# |
30
|
|
|
|
|
|
|
# get_things - return a unique list of things found |
31
|
|
|
|
|
|
|
# |
32
|
|
|
|
|
|
|
############################################################################### |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub get_things { |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
0
|
1
|
|
my ($thing_string) = @_; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my @things; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# what are all the suffixes |
41
|
0
|
|
|
|
|
|
foreach my $type (Goo::TypeManager::get_all_types()) { |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
#use Goo::Prompter; |
44
|
|
|
|
|
|
|
#Goo::Prompter::notify("looing for $type "); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# search the file for Things! |
47
|
0
|
|
|
|
|
|
while ($thing_string =~ m/([\w\.\-]+)\.$type/sg) { |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my $prefix = $1; |
50
|
0
|
|
|
|
|
|
my $suffix = $type; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# print "found $1 \. $type \n"; |
53
|
0
|
|
|
|
|
|
push(@things, $prefix . "." . $suffix); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# remove repeats |
60
|
0
|
|
|
|
|
|
my %unique_things = map { $_ => 1 } @things; |
|
0
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
return keys %unique_things; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
############################################################################### |
68
|
|
|
|
|
|
|
# |
69
|
|
|
|
|
|
|
# get_table - show a text based table of things |
70
|
|
|
|
|
|
|
# |
71
|
|
|
|
|
|
|
############################################################################### |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub get_table { |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
0
|
1
|
|
my ($thing, $index, $options) = @_; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
my @things = get_things($thing); |
78
|
|
|
|
|
|
|
|
79
|
0
|
0
|
|
|
|
|
return unless @things; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# prepare the head of the table |
82
|
0
|
|
|
|
|
|
my $table = Text::FormatTable->new('5l 30l'); |
83
|
0
|
|
|
|
|
|
$table->head('', 'Things'); |
84
|
0
|
|
|
|
|
|
$table->rule('-'); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# populate the table |
87
|
0
|
|
|
|
|
|
foreach my $thing (@things) { |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# pop off the options |
90
|
0
|
|
|
|
|
|
my $counter = shift(@$options); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# remember the index position |
93
|
0
|
|
|
|
|
|
$index->{$counter} = $thing; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# display a row |
96
|
0
|
|
|
|
|
|
$table->row("[$counter]", $thing); |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# show the whole thing |
101
|
0
|
|
|
|
|
|
print $table->render(); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
############################################################################### |
107
|
|
|
|
|
|
|
# |
108
|
|
|
|
|
|
|
# run_driver - drive the module |
109
|
|
|
|
|
|
|
# |
110
|
|
|
|
|
|
|
############################################################################### |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub run_driver { |
113
|
|
|
|
|
|
|
|
114
|
0
|
|
|
0
|
1
|
|
my ($thing) = get_things("goo.goo"); |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
print $thing . "\n"; |
117
|
|
|
|
|
|
|
# print $thing->to_string(); |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
# call the driver |
122
|
|
|
|
|
|
|
run_driver() unless caller(); |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
1; |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
__END__ |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 NAME |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Goo::ThingFinder - Find all the "Things" in a string |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head1 SYNOPSIS |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
use Goo::ThingFinder; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 DESCRIPTION |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 METHODS |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=over |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item get_things |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
return a unique list of Things found |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=item get_table |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
show a text based table of Things |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item run_driver |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
drive the module |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=back |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 AUTHOR |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Nigel Hamilton <nigel@trexy.com> |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 SEE ALSO |
162
|
|
|
|
|
|
|
|