Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl Errors

Status
Not open for further replies.

MJAZ

Programmer
Aug 1, 2006
73
US
I am running a script that generates my pages dynamically using HTML::Template and CGI. My website has over 50 static HTML pages right now and I need to generate them dynamically. Here is the code:

#!C:/Perl/bin/perl.exe -wT

use CGI;
use HTML::Template;
use strict;

my $query = new CGI;
my $content = $query->param( "content" );

$ENV{DOCUMENT_ROOT} = "C:/Program Files/Apache Software Foundation/Apache2.2";

my $template_file = $ENV{DOCUMENT_ROOT}."/templates/main.tmpl";


unless ( $content ) {
print_index();
}

sub print_index {

my $maincontent_file_index = $ENV{DOCUMENT_ROOT}."/templates/content/index/maincontent.txt";
my $footercontent_index = $ENV{DOCUMENT_ROOT}."/templates/content/index/indexfootercontent.txt";
my $dropdown = $ENV{DOCUMENT_ROOT}."/templates/content/dropmenu.txt";
my $index_tmpl = $ENV{DOCUMENT_ROOT}."/templates/index.tmpl";
my @data1;
my @data2;
my @data3;
my $tmpl = new HTML::Template( filename => $index_tmpl );

my @content = [ content => @data1 ];
my @footer = [ footer => @data2 ];
my @dropdown = [ dropdown => @data3 ];

open(FILE,$maincontent_file_index) || die ("Could not open file:" .$!);
@data1 = <FILE>;
close (FILE);

open(FILE,$footercontent_index) || die ("Could not open file:" .$!);
@data2 = <FILE>;
close (FILE);

open(FILE,$dropdown) || die ("Could not open file:" .$!);
@data3 = <FILE>;
close (FILE);

$tmpl->param ( content => @content,
footer => @footer,
dropmenu => @dropdown );

print "Content-type: text/html\n\n";
print $tmpl->output;
exit;
}

What it's supposed to do is open the text files and put their contents in to a TMPL_VAR or whatever need be. In this case, this is the home page, so it basically has a footer, the main content, and a drop-down menu that is impossible to edit without using this dynamic generation script. Could you please help me make it open the files, read their contents and print their contents in HTML using HTML::Template? I will be very grateful if I could have some help.
 
Could you post a sample of the text files so we know what we're working with?

- George
 
Why did you start another thread for this question?
I sent you some feedback to your question in this thread:
thread219-1263003
And I don't remember seeing any answers to it.
Was my post of no use?



Trojan.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top