line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Goo::Thing::gml::Writer; |
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::Writer.pm |
13
|
|
|
|
|
|
|
# Description: Goo Markup Language |
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
|
|
5
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
25
|
|
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
6
|
use Goo::FileUtilities; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
17
|
|
25
|
1
|
|
|
1
|
|
6
|
use Goo::CompressWhitespace; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
239
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
############################################################################### |
29
|
|
|
|
|
|
|
# |
30
|
|
|
|
|
|
|
# write - write a hash to disk |
31
|
|
|
|
|
|
|
# |
32
|
|
|
|
|
|
|
############################################################################### |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub write { |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
0
|
1
|
|
my ($thing, $filename) = @_; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
Goo::FileUtilities::write_file($filename, stringify_hash($thing)); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
############################################################################### |
44
|
|
|
|
|
|
|
# |
45
|
|
|
|
|
|
|
# stringify_hash - turn a hash into a string |
46
|
|
|
|
|
|
|
# |
47
|
|
|
|
|
|
|
############################################################################### |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub stringify_hash { |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
0
|
1
|
|
my ($hash) = @_; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
my $string; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
foreach my $field (keys %$hash) { |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
my $value = $hash->{$field}; |
58
|
|
|
|
|
|
|
|
59
|
0
|
0
|
|
|
|
|
if (ref($value) eq "ARRAY") { |
60
|
0
|
|
|
|
|
|
$value = join("||", @{ $hash->{$field} }); |
|
0
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
$value =~ s/\s+$//g; |
62
|
0
|
|
|
|
|
|
$value =~ s/^\s+//g; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
0
|
0
|
0
|
|
|
|
next unless ($field && $value); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# watch out for embedded hashes |
68
|
0
|
0
|
|
|
|
|
next if ($value =~ /^HASH/); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
$string .= "<$field>$value</$field>\n"; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
return $string; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__END__ |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 NAME |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Goo::Thing::gml::Writer - Write a Goo Markup Language (GML) Thing |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 SYNOPSIS |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
use Goo::Thing::gml::Writer; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 DESCRIPTION |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 METHODS |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=over |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item write |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
write a hash to disk |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item stringify_hash |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
turn a hash into a string |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=back |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 AUTHOR |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Nigel Hamilton <nigel@trexy.com> |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 SEE ALSO |
117
|
|
|
|
|
|
|
|