| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package CGI::Template; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
20863
|
use 5.012004; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
34
|
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
40
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
7
|
|
|
|
1
|
|
|
|
|
41
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
117
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require Exporter; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
1
|
|
|
|
|
2215
|
use vars qw( |
|
12
|
|
|
|
|
|
|
$VERSION $FORM_CHECK @ISA @EXPORT @EXPORT_OK $DOCTYPE $STRICT |
|
13
|
|
|
|
|
|
|
$TRANSITIONAL $FRAMESET $HTML5 |
|
14
|
1
|
|
|
1
|
|
5
|
); |
|
|
1
|
|
|
|
|
2
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
|
21
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
|
22
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# This allows declaration use CGI::Template ':all'; |
|
25
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
|
26
|
|
|
|
|
|
|
# will save memory. |
|
27
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
) ] ); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
our @EXPORT = qw(); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# These variables just define standard HTML DOCTYPEs. We'll use them throughout. |
|
39
|
|
|
|
|
|
|
$STRICT = qq{\n\n}; |
|
40
|
|
|
|
|
|
|
$TRANSITIONAL = qq{\n\n}; |
|
41
|
|
|
|
|
|
|
$FRAMESET = qq{\n\n}; |
|
42
|
|
|
|
|
|
|
$HTML5 = qq{}; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# Use HTML5 by default. |
|
45
|
|
|
|
|
|
|
$DOCTYPE = $HTML5; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# |
|
51
|
|
|
|
|
|
|
# |
|
52
|
|
|
|
|
|
|
# |
|
53
|
|
|
|
|
|
|
sub new { |
|
54
|
1
|
|
|
1
|
1
|
13
|
my $class = shift; |
|
55
|
|
|
|
|
|
|
|
|
56
|
1
|
|
|
|
|
2
|
my %passed_hash = @_; |
|
57
|
|
|
|
|
|
|
|
|
58
|
1
|
|
|
|
|
2
|
my $doctype = $passed_hash{doctype}; |
|
59
|
1
|
|
|
|
|
3
|
my $request_method = $passed_hash{request}; |
|
60
|
1
|
|
|
|
|
3
|
my $template_dir = $passed_hash{templates}; |
|
61
|
|
|
|
|
|
|
|
|
62
|
1
|
50
|
|
|
|
3
|
$template_dir = "templates" unless $template_dir; |
|
63
|
|
|
|
|
|
|
|
|
64
|
1
|
|
|
|
|
3
|
my $crm = $ENV{'REQUEST_METHOD'}; |
|
65
|
|
|
|
|
|
|
|
|
66
|
1
|
50
|
|
|
|
4
|
if( $request_method ){ |
|
67
|
0
|
0
|
|
|
|
0
|
if( $request_method =~ /^get$/i ){ |
|
|
|
0
|
|
|
|
|
|
|
68
|
0
|
0
|
|
|
|
0
|
unless( $crm =~ /^get$/i ){ |
|
69
|
0
|
|
|
|
|
0
|
&error("Incorrect request method"); |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
} elsif( $request_method =~ /^post$/i ){ |
|
73
|
0
|
0
|
|
|
|
0
|
unless( $crm =~ /^post$/i ){ |
|
74
|
0
|
|
|
|
|
0
|
&error("Incorrect request method"); |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
} else { |
|
78
|
0
|
|
|
|
|
0
|
croak "CGI::Template : Invalid request argument passed to new(): $request_method"; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
|
83
|
1
|
50
|
|
|
|
4
|
$doctype = "" unless $doctype; |
|
84
|
|
|
|
|
|
|
|
|
85
|
1
|
50
|
33
|
|
|
19
|
if( $doctype =~ /^transitional$/i || $doctype =~ /^loose$/i ){ |
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
0
|
$DOCTYPE = $TRANSITIONAL; |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
} elsif( $doctype =~ /^frameset$/i ){ |
|
89
|
0
|
|
|
|
|
0
|
$DOCTYPE = $FRAMESET; |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
} elsif( $doctype =~ /^strict$/i ){ |
|
92
|
0
|
|
|
|
|
0
|
$DOCTYPE = $STRICT; |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
} elsif( $doctype =~ /^html5$/i ){ |
|
95
|
0
|
|
|
|
|
0
|
$DOCTYPE = $HTML5; |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
} elsif( $doctype =~ /^none$/i ){ |
|
98
|
0
|
|
|
|
|
0
|
$DOCTYPE = ""; |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
} elsif( $doctype =~ /^$/i ){ |
|
101
|
1
|
|
|
|
|
3
|
$DOCTYPE = $HTML5; |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
} else { |
|
104
|
0
|
|
|
|
|
0
|
croak "CGI::Template : Invalid doctype argument passed to new(): $doctype"; |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
|
|
107
|
1
|
|
|
|
|
2
|
my $path = $ENV{PATH_INFO}; |
|
108
|
1
|
50
|
|
|
|
4
|
if( $path ){ |
|
109
|
0
|
|
|
|
|
0
|
$path =~ s/^\/+//; |
|
110
|
0
|
|
|
|
|
0
|
$path =~ s/\/+$//; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
1
|
|
|
|
|
5
|
my $self = { |
|
114
|
|
|
|
|
|
|
path => $path, |
|
115
|
|
|
|
|
|
|
templates => $template_dir, |
|
116
|
|
|
|
|
|
|
}; |
|
117
|
1
|
|
|
|
|
7
|
my $template = &_check_template( $template_dir ); |
|
118
|
1
|
50
|
|
|
|
4
|
$self->{template} = $template if( $template ); |
|
119
|
|
|
|
|
|
|
|
|
120
|
1
|
|
|
|
|
3
|
bless($self, $class); |
|
121
|
1
|
|
|
|
|
5
|
return $self; |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub header { |
|
129
|
1
|
|
|
1
|
1
|
5
|
my $self = shift; |
|
130
|
1
|
|
|
|
|
3
|
my %passed_hash = @_; |
|
131
|
|
|
|
|
|
|
|
|
132
|
1
|
|
|
|
|
3
|
my $header = "Content-type: text/html\n"; |
|
133
|
|
|
|
|
|
|
|
|
134
|
1
|
|
|
|
|
2
|
my $redirect = 0; |
|
135
|
1
|
|
|
|
|
4
|
foreach my $i (keys %passed_hash){ |
|
136
|
0
|
0
|
|
|
|
0
|
if( $i =~ /-cookie/ ){ |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
137
|
0
|
|
|
|
|
0
|
$header .= "Set-Cookie: " . $passed_hash{$i} . "\n"; |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
} elsif( $i =~ /-content-type/ ) { |
|
140
|
0
|
|
|
|
|
0
|
$header =~ s/text\/html/$passed_hash{$i}/; |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
} elsif( $i =~ /-redirect/ ) { |
|
143
|
0
|
|
|
|
|
0
|
$header =~ s/Content-type: .*?\n/Status: 302 Found\nLocation: $passed_hash{$i}\n/m; |
|
144
|
0
|
|
|
|
|
0
|
$redirect++; |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
} else { |
|
147
|
0
|
|
|
|
|
0
|
$header .= "$i: " . $passed_hash{$i} . "\n"; |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
|
|
151
|
1
|
|
|
|
|
2
|
$header .= "\n"; |
|
152
|
1
|
50
|
|
|
|
12
|
$header .= $DOCTYPE unless $redirect; |
|
153
|
|
|
|
|
|
|
|
|
154
|
1
|
|
|
|
|
5
|
return $header; |
|
155
|
|
|
|
|
|
|
} |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub path { |
|
158
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
159
|
0
|
|
|
|
|
0
|
return $self->{path}; |
|
160
|
|
|
|
|
|
|
} |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub content { |
|
164
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
165
|
0
|
|
|
|
|
0
|
my %hash = @_; |
|
166
|
|
|
|
|
|
|
|
|
167
|
0
|
0
|
|
|
|
0
|
croak "CGI::Template : No template set!" unless defined $self->{template}; |
|
168
|
|
|
|
|
|
|
|
|
169
|
0
|
|
|
|
|
0
|
my $data = $self->{template}; |
|
170
|
|
|
|
|
|
|
|
|
171
|
0
|
|
|
|
|
0
|
foreach my $i (keys %hash){ |
|
172
|
0
|
|
|
|
|
0
|
$data =~ s/#!$i!#/$hash{$i}/g; |
|
173
|
|
|
|
|
|
|
} |
|
174
|
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
0
|
return $data; |
|
176
|
|
|
|
|
|
|
} |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub replace_template { |
|
179
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
180
|
0
|
|
|
|
|
0
|
my $template = shift; |
|
181
|
0
|
|
|
|
|
0
|
$self->{template} = $template; |
|
182
|
|
|
|
|
|
|
} |
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
sub error { |
|
185
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
186
|
0
|
|
|
|
|
0
|
my $message = shift; |
|
187
|
|
|
|
|
|
|
|
|
188
|
0
|
|
|
|
|
0
|
my $template_dir = $self->{templates}; |
|
189
|
|
|
|
|
|
|
|
|
190
|
0
|
|
|
|
|
0
|
my $error_template = ''; |
|
191
|
0
|
0
|
|
|
|
0
|
if( -e "$template_dir/error.html" ){ |
|
192
|
0
|
|
|
|
|
0
|
my $fail = 0; |
|
193
|
0
|
0
|
|
|
|
0
|
open INFILE, "$template_dir/error.html" or $fail = 1; |
|
194
|
0
|
0
|
|
|
|
0
|
if( $fail ) { croak "CGI::Template : Couldn't open error template: $template_dir/error.html"; return 0; } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
195
|
|
|
|
|
|
|
{ |
|
196
|
0
|
|
|
|
|
0
|
local $/; |
|
|
0
|
|
|
|
|
0
|
|
|
197
|
0
|
|
|
|
|
0
|
$error_template = ; |
|
198
|
|
|
|
|
|
|
} |
|
199
|
0
|
|
|
|
|
0
|
close INFILE; |
|
200
|
|
|
|
|
|
|
} |
|
201
|
|
|
|
|
|
|
|
|
202
|
0
|
0
|
|
|
|
0
|
$error_template = qq{ |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
Error |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
Oops! |
|
207
|
|
|
|
|
|
|
#!MESSAGE!# |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
} unless( $error_template ); |
|
213
|
|
|
|
|
|
|
|
|
214
|
0
|
|
|
|
|
0
|
$error_template =~ s/#!MESSAGE!#/$message/g; |
|
215
|
0
|
|
|
|
|
0
|
print &header; |
|
216
|
0
|
|
|
|
|
0
|
print $error_template; |
|
217
|
0
|
|
|
|
|
0
|
exit; |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
} |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
sub get_template { |
|
223
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
224
|
0
|
|
|
|
|
0
|
my $file = shift; |
|
225
|
0
|
|
|
|
|
0
|
my %passed_hash = @_; |
|
226
|
0
|
|
|
|
|
0
|
my $fail = 0; |
|
227
|
|
|
|
|
|
|
|
|
228
|
0
|
|
|
|
|
0
|
my $template_dir = $self->{templates}; |
|
229
|
|
|
|
|
|
|
|
|
230
|
0
|
|
|
|
|
0
|
my @templates = ( |
|
231
|
|
|
|
|
|
|
"$template_dir/$file.html", |
|
232
|
|
|
|
|
|
|
"$template_dir/$file", |
|
233
|
|
|
|
|
|
|
); |
|
234
|
|
|
|
|
|
|
|
|
235
|
0
|
|
|
|
|
0
|
my $tn = ''; |
|
236
|
0
|
|
|
|
|
0
|
foreach my $i (@templates){ |
|
237
|
0
|
0
|
|
|
|
0
|
if( -e $i ){ |
|
238
|
0
|
|
|
|
|
0
|
$tn = $i; |
|
239
|
0
|
|
|
|
|
0
|
last; |
|
240
|
|
|
|
|
|
|
} |
|
241
|
|
|
|
|
|
|
} |
|
242
|
|
|
|
|
|
|
|
|
243
|
0
|
0
|
|
|
|
0
|
unless($tn){ |
|
244
|
0
|
|
|
|
|
0
|
carp "CGI::Template : Couldn't find valid template: ".join(", ", @templates)." called by $tn"; |
|
245
|
0
|
0
|
|
|
|
0
|
return (0) unless $tn; |
|
246
|
|
|
|
|
|
|
} |
|
247
|
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
|
|
249
|
0
|
0
|
|
|
|
0
|
open INFILE, $tn or $fail = 1; |
|
250
|
0
|
0
|
|
|
|
0
|
if( $fail ) { carp "CGI::Template : Couldn't open template: $file, called by $tn"; return 0; } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
251
|
|
|
|
|
|
|
|
|
252
|
0
|
|
|
|
|
0
|
my $data = ''; |
|
253
|
|
|
|
|
|
|
{ |
|
254
|
0
|
|
|
|
|
0
|
local $/; |
|
|
0
|
|
|
|
|
0
|
|
|
255
|
0
|
|
|
|
|
0
|
$data = ; |
|
256
|
|
|
|
|
|
|
} |
|
257
|
0
|
|
|
|
|
0
|
close INFILE; |
|
258
|
|
|
|
|
|
|
|
|
259
|
0
|
|
|
|
|
0
|
foreach my $i (keys %passed_hash){ |
|
260
|
0
|
|
|
|
|
0
|
$i = uc($i); |
|
261
|
0
|
|
|
|
|
0
|
$data =~ s/#!$i!#/$passed_hash{$i}/g; |
|
262
|
|
|
|
|
|
|
} |
|
263
|
|
|
|
|
|
|
|
|
264
|
0
|
|
|
|
|
0
|
return $data; |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
} |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
sub template { |
|
270
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
|
271
|
0
|
|
|
|
|
0
|
return $self->{template}; |
|
272
|
|
|
|
|
|
|
} |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
########################################################### |
|
277
|
|
|
|
|
|
|
# PRIVATE METHODS |
|
278
|
|
|
|
|
|
|
########################################################### |
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
sub _check_template { |
|
281
|
1
|
|
|
1
|
|
2
|
my $template_dir = shift; |
|
282
|
|
|
|
|
|
|
|
|
283
|
1
|
|
|
|
|
4
|
my $name = $0; |
|
284
|
|
|
|
|
|
|
|
|
285
|
1
|
|
|
|
|
3
|
$name =~ s/\/$//; |
|
286
|
1
|
|
|
|
|
7
|
$name =~ s/^.*\///; |
|
287
|
1
|
|
|
|
|
8
|
$name =~ s/\.cgi$//; |
|
288
|
1
|
|
|
|
|
3
|
$name =~ s/\.pl$//; |
|
289
|
|
|
|
|
|
|
|
|
290
|
1
|
|
|
|
|
7
|
my @templates = ( |
|
291
|
|
|
|
|
|
|
"$template_dir/$name.html", |
|
292
|
|
|
|
|
|
|
"$template_dir/$name", |
|
293
|
|
|
|
|
|
|
"$template_dir/default.html" |
|
294
|
|
|
|
|
|
|
); |
|
295
|
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
|
|
297
|
1
|
|
|
|
|
3
|
my $head_template = ''; |
|
298
|
1
|
50
|
|
|
|
19
|
if( -e "$template_dir/head.html" ){ |
|
299
|
0
|
|
|
|
|
0
|
my $fail = 0; |
|
300
|
0
|
0
|
|
|
|
0
|
open INFILE, "$template_dir/head.html" or $fail = 1; |
|
301
|
0
|
0
|
|
|
|
0
|
if( $fail ) { croak "CGI::Template : Couldn't open general template: $template_dir/head.html, called by $name"; return 0; } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
302
|
|
|
|
|
|
|
{ |
|
303
|
0
|
|
|
|
|
0
|
local $/; |
|
|
0
|
|
|
|
|
0
|
|
|
304
|
0
|
|
|
|
|
0
|
$head_template = ; |
|
305
|
|
|
|
|
|
|
} |
|
306
|
0
|
|
|
|
|
0
|
close INFILE; |
|
307
|
|
|
|
|
|
|
} |
|
308
|
|
|
|
|
|
|
|
|
309
|
1
|
|
|
|
|
2
|
my $tn = ''; |
|
310
|
1
|
|
|
|
|
3
|
foreach my $i (@templates){ |
|
311
|
3
|
50
|
|
|
|
23
|
if( -e $i ){ |
|
312
|
0
|
|
|
|
|
0
|
$tn = $i; |
|
313
|
0
|
|
|
|
|
0
|
last; |
|
314
|
|
|
|
|
|
|
} |
|
315
|
|
|
|
|
|
|
} |
|
316
|
|
|
|
|
|
|
|
|
317
|
1
|
50
|
|
|
|
7
|
return (0) unless $tn; |
|
318
|
|
|
|
|
|
|
|
|
319
|
0
|
|
|
|
|
|
my $fail = 0; |
|
320
|
0
|
0
|
|
|
|
|
open INFILE, $tn or $fail = 1; |
|
321
|
|
|
|
|
|
|
|
|
322
|
0
|
0
|
|
|
|
|
if( $fail ) { carp "CGI::Template : Couldn't open template: $tn, called by $name"; return 0; } |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
|
|
324
|
0
|
|
|
|
|
|
my $data = ''; |
|
325
|
|
|
|
|
|
|
{ |
|
326
|
0
|
|
|
|
|
|
local $/; |
|
|
0
|
|
|
|
|
|
|
|
327
|
0
|
|
|
|
|
|
$data = ; |
|
328
|
|
|
|
|
|
|
} |
|
329
|
0
|
|
|
|
|
|
close INFILE; |
|
330
|
|
|
|
|
|
|
|
|
331
|
0
|
|
|
|
|
|
my $template = ""; |
|
332
|
|
|
|
|
|
|
|
|
333
|
0
|
0
|
|
|
|
|
if( $head_template ){ |
|
334
|
0
|
|
|
|
|
|
$template = $head_template; |
|
335
|
0
|
|
|
|
|
|
$template =~ s/#!DATA!#/$data/; |
|
336
|
|
|
|
|
|
|
} else { |
|
337
|
0
|
|
|
|
|
|
$template = $data; |
|
338
|
|
|
|
|
|
|
} |
|
339
|
|
|
|
|
|
|
|
|
340
|
0
|
|
|
|
|
|
return $template; |
|
341
|
|
|
|
|
|
|
|
|
342
|
|
|
|
|
|
|
} |
|
343
|
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
|
|
345
|
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
|
|
347
|
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
|
|
349
|
|
|
|
|
|
|
|
|
350
|
|
|
|
|
|
|
1; |
|
351
|
|
|
|
|
|
|
__END__ |