B
barrybevel
Hi,
I have a Perl cgi program which can return a number of different HTML
pages based on input.
I am using Here Documents to hold the HTML pages with $variables to
output dynamic content.
The way I'm doing it is becoming very sloppy and unmanageable.
Can someone suggest a better/cleaner way of seperating dynamic HTML
and perl code?
Here's an example of what I'm doing (shame on me):
my $webpage;
my $var1;
my $var2;
....
if( ...) {
open (FILE, 'good-page.pl') or die "blah...";
my @code = <FILE>;
eval join("\n", @code);
} else {
open (FILE, 'bad-page.pl') or die "blah...";
my @code = <FILE>;
eval join("\n", @code);
}
....
print "http headers...";
print $webpage;
############################################
# good-page.pl
$webpage = <<PAGE;
<html>
....
Good Page $var1
....
</html>
PAGE
############################################
# bad-page.pl
$webpage = <<PAGE;
<html>
....
Bad Page $var2
....
</html>
PAGE
I have a Perl cgi program which can return a number of different HTML
pages based on input.
I am using Here Documents to hold the HTML pages with $variables to
output dynamic content.
The way I'm doing it is becoming very sloppy and unmanageable.
Can someone suggest a better/cleaner way of seperating dynamic HTML
and perl code?
Here's an example of what I'm doing (shame on me):
my $webpage;
my $var1;
my $var2;
....
if( ...) {
open (FILE, 'good-page.pl') or die "blah...";
my @code = <FILE>;
eval join("\n", @code);
} else {
open (FILE, 'bad-page.pl') or die "blah...";
my @code = <FILE>;
eval join("\n", @code);
}
....
print "http headers...";
print $webpage;
############################################
# good-page.pl
$webpage = <<PAGE;
<html>
....
Good Page $var1
....
</html>
PAGE
############################################
# bad-page.pl
$webpage = <<PAGE;
<html>
....
Bad Page $var2
....
</html>
PAGE