First thing: I have posted a problem similar to this before. But before you get all pissed at me, look at my problem and answer me with an answer I need.
My problem is this: My script uses a hash with values of form fields and file locations. It is supposed to take the value of the form field, use it inside a hash, and then open the value of the hashas the filename to open. Here is my code:
And here is the error I get:
I know the file exists. How can I make it work, without me having to re-write the entire script with over 8 if and elsif statements?
My problem is this: My script uses a hash with values of form fields and file locations. It is supposed to take the value of the form field, use it inside a hash, and then open the value of the hashas the filename to open. Here is my code:
Code:
my $content = $query->param( "content" );
my $rootpath = $ENV{DOCUMENT_ROOT} . "/templates";
my $contentpath = "$rootpath/content";
my %contentfiles = ( login => "$contentpath/logincontent.txt",
passfnd => "$contentpath/passfndcontent.txt",
signup => "$contentpath/signupcontent.txt",
services => "$contentpath/servicescontent.txt",
compare => "$contentpath/comparecontent.txt",
capabilities => "$contentpath/capabilitiescontent.txt",
violation => "$contentpath/violationscontent.txt",
billing => "$contentpath/billingcontent.txt",
other => "$contentpath/othercontactscontent.txt",
about => "$contentpath/aboutcontent.txt",
history => "$contentpath/historycontent.txt",
);
my $template_file = $ENV{DOCUMENT_ROOT}."/templates/main.tmpl";
my $tmpl = new HTML::Template( filename => $template_file );
my $dropdown = $ENV{DOCUMENT_ROOT}."/templates/content/dropmenu.txt";
my $contentfile = read_file($contentfiles{$content});
my $dropmenu = read_file($dropdown);
$tmpl->param ( content => $contentfile,
dropdown => $dropmenu );
And here is the error I get:
Code:
read_file 'C:/Program Files/Apache Software Foundation/Apache2.2/templates/content/aboutcontent.txt' - sysopen: No such file or directory at C:\PROGRA~1\APACHE~2\Apache2.2\htdocs\index.cgi line 68
I know the file exists. How can I make it work, without me having to re-write the entire script with over 8 if and elsif statements?