| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Goo::Thing::gml::Reader; |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
############################################################################### |
|
6
|
|
|
|
|
|
|
# Nigel Hamilton |
|
7
|
|
|
|
|
|
|
# |
|
8
|
|
|
|
|
|
|
# Copyright Nigel Hamilton 2005 |
|
9
|
|
|
|
|
|
|
# All Rights Reserved |
|
10
|
|
|
|
|
|
|
# |
|
11
|
|
|
|
|
|
|
# Author: Nigel Hamilton |
|
12
|
|
|
|
|
|
|
# Filename: Goo::Thing::gml::Reader.pm |
|
13
|
|
|
|
|
|
|
# Description: Read a Goo Markup page |
|
14
|
|
|
|
|
|
|
# |
|
15
|
|
|
|
|
|
|
# Date Change |
|
16
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------- |
|
17
|
|
|
|
|
|
|
# 27/06/2005 Auto generated file |
|
18
|
|
|
|
|
|
|
# 27/06/2005 Not quite XML - need to read and write Goo XML |
|
19
|
|
|
|
|
|
|
# |
|
20
|
|
|
|
|
|
|
############################################################################### |
|
21
|
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
6554
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
34
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
5
|
use Goo::FileUtilities; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
19
|
|
|
25
|
1
|
|
|
1
|
|
6
|
use Goo::CompressWhitespace; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
385
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
############################################################################### |
|
29
|
|
|
|
|
|
|
# |
|
30
|
|
|
|
|
|
|
# read - slurp in a file and parse it |
|
31
|
|
|
|
|
|
|
# |
|
32
|
|
|
|
|
|
|
############################################################################### |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub read { |
|
35
|
|
|
|
|
|
|
|
|
36
|
0
|
|
|
0
|
1
|
|
my ($filename) = @_; |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# print "$filename \n"; |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# slurp mode |
|
41
|
0
|
|
|
|
|
|
my $data; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# a hash of stuff |
|
44
|
0
|
|
|
|
|
|
my $thing = {}; |
|
45
|
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
eval { $data = Goo::FileUtilities::get_file_as_string($filename); }; |
|
|
0
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# nothing found! bailout now |
|
49
|
0
|
0
|
|
|
|
|
if ($@) { return $thing; } |
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# parse here! |
|
52
|
0
|
|
|
|
|
|
while ($data =~ m|<([^>]*)>(.*?)</\1>|gs) { |
|
53
|
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
my $field = $1; |
|
55
|
0
|
|
|
|
|
|
my $value = $2; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# compress all objects except for emailtemplates |
|
58
|
|
|
|
|
|
|
#if (($value =~ /<[^>]*>/) && ($type ne "emailtemplate")) { |
|
59
|
|
|
|
|
|
|
# # compress the object, save RAM and gain speed - strip leading whitespace |
|
60
|
|
|
|
|
|
|
# CompressWhitespace::compress_html(\$value); |
|
61
|
|
|
|
|
|
|
# |
|
62
|
|
|
|
|
|
|
#} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# print "$value"; |
|
65
|
|
|
|
|
|
|
# a hash of a hash of a hash - wow |
|
66
|
0
|
0
|
|
|
|
|
if ($value =~ /\|\|/) { |
|
67
|
0
|
|
|
|
|
|
my @values = split(/\|\|/, $value); |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# this is an array of stuff |
|
70
|
0
|
|
|
|
|
|
$thing->{$field} = \@values; |
|
71
|
|
|
|
|
|
|
} else { |
|
72
|
0
|
|
|
|
|
|
$thing->{$field} = $value; |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
return $thing; |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
############################################################################### |
|
83
|
|
|
|
|
|
|
# |
|
84
|
|
|
|
|
|
|
# write - write a hash to disk |
|
85
|
|
|
|
|
|
|
# |
|
86
|
|
|
|
|
|
|
############################################################################### |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub write { |
|
89
|
|
|
|
|
|
|
|
|
90
|
0
|
|
|
0
|
1
|
|
my ($thing, $filename) = @_; |
|
91
|
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
Goo::FileUtilities::write_file($filename, stringify_hash($thing)); |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
############################################################################### |
|
98
|
|
|
|
|
|
|
# |
|
99
|
|
|
|
|
|
|
# stringify_hash - turn a hash into a string |
|
100
|
|
|
|
|
|
|
# |
|
101
|
|
|
|
|
|
|
############################################################################### |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub stringify_hash { |
|
104
|
|
|
|
|
|
|
|
|
105
|
0
|
|
|
0
|
1
|
|
my ($hash) = @_; |
|
106
|
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
my $string; |
|
108
|
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
foreach my $field (keys %$hash) { |
|
110
|
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
my $value = $hash->{$field}; |
|
112
|
|
|
|
|
|
|
|
|
113
|
0
|
0
|
|
|
|
|
if (ref($value) eq "ARRAY") { |
|
114
|
0
|
|
|
|
|
|
$value = join("||", @{ $hash->{$field} }); |
|
|
0
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
$value =~ s/\s+$//g; |
|
116
|
0
|
|
|
|
|
|
$value =~ s/^\s+//g; |
|
117
|
|
|
|
|
|
|
} |
|
118
|
|
|
|
|
|
|
|
|
119
|
0
|
0
|
0
|
|
|
|
next unless ($field && $value); |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
# watch out for embedded hashes |
|
122
|
0
|
0
|
|
|
|
|
next if ($value =~ /^HASH/); |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
$string .= "<$field>$value</$field>\n"; |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
return $string; |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
} |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
1; |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
__END__ |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head1 NAME |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Goo::Thing::gml::Reader - Read a Goo Markup Language (GML) Thing |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
use Goo::Thing::gml::Reader; |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 METHODS |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=over |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item read |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
slurp in a file and parse it |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=item write |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
write a hash to disk |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=item stringify_hash |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
turn a hash into a string |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=back |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head1 AUTHOR |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
Nigel Hamilton <nigel@trexy.com> |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
175
|
|
|
|
|
|
|
|