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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read_File Error

Status
Not open for further replies.

MJAZ

Programmer
Joined
Aug 1, 2006
Messages
73
Location
US
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:

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?
 
it doesn't appear to be a problem with using a hash, the filename seems to be correct according to you:

C:/Program Files/Apache Software Foundation/Apache2.2/templates/content/aboutcontent.txt

but I don't know why sysopen can't find the file. Can you post line 68 or the section of code line 68 is in (point out line 68 though if it's not obvious)'



 
Thanks for your help but I fixed it now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top