homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

Help with line of Perl code
Problem with perl coding

 12:45 pm on Apr 17, 2007 (gmt 0)

Hi All,

I am not a programmer but have a perl programme which I have recently transferred from a NT4 server to a Windows 2003 server. Everything else is the same except possibly a different version of Perl is running on the server.

I get the following error message:

Software error:
couldn't open datafile No such file or directory at D:\FTP\cym\Htdocs\cgi-bin\inn-i.pl line 1405.For help, please send mail to this site's webmaster, giving this error message and the time and date of the error.

The code around line 1405 is as follows:

print $IN->header;
print $IN->start_html("Innovation Software Superuser Maintenance Page");
open IN, "<$datafiles/maint.html" or die "couldn't open datafile $!";
while (my $line = <IN>){
$line =~ s/_INN_EXEC_/$inn_exec/g;
print $line;

And the file containing the datafiles reference says:

$datafiles = 'D:\FTP\cym\htdocs\cgi-bin\inn-i';

I can confirm that this folder exists and maint.html exists.

Could anyone help me correct the error please?





 1:18 pm on Apr 17, 2007 (gmt 0)

Can't help you much on this one, but for further debugging I would extend the `die`-string to include the $datafiles variable to get an idea of its exact content at the time the script breaks, and then start from there:
... or die "couldn't open datafile $datafiles -- $!";

Kind regards,


 1:40 pm on Apr 17, 2007 (gmt 0)

ok, I think this is it.

Take the filename in your open statement:


and resolve $datafiles


See that? Try changing your open line to "<$datafiles\\maint.html". You have to use a double \ as it's a special character.


 5:38 pm on Apr 17, 2007 (gmt 0)

this is not a problem:


but it's a good habit to get into to use all forward slashes in directory paths, even if you are on windows, it will not matter:


this avoids unwanted meta character interpolation if you use the back-slashes in a string that gets interpolated. In this case, the single-quotes would have avoided that but still better to use forward-slashes as a rule.

The problem appears to be that the path or the filename is not correct.


 10:07 pm on Apr 17, 2007 (gmt 0)

Thanks perl_diver, I have used both on Win32, but didn't know about mixing them.

In that case the only thing I could suggest is that maybe inn-i isn't supposed to be in the path, or maybe the maint.html is in the wrong directory. It may be a security issue, if you're on Windows Server you're probably using IIS, check that IUSR_#*$!#*$!x has access to the file.

Also try Romeo's suggestion of adding $datafiles to the error message, this will allow you to definitively check the correct path.


 1:06 am on Apr 18, 2007 (gmt 0)

"No such file or directory" means it can't be found. "Permission denied" would mean the file is either open (a windows thing) or the user (or maybe the script) does not have permission.


 4:27 am on Apr 18, 2007 (gmt 0)

$datafiles = 'D:\FTP\cym\htdocs\cgi-bin\inn-i';

could it be a case sensitivity problem?
i noticed your error message refers to this directory with an uppercase H for "Htdocs" in the script path:

couldn't open datafile No such file or directory at D:\FTP\cym\Htdocs\cgi-bin\inn-i.pl line 1405...


 11:24 am on Apr 18, 2007 (gmt 0)

Nope, Windows filesystem is not case sensitive.


 2:14 pm on Apr 19, 2007 (gmt 0)

$datafiles = 'D:/FTP/cym/htdocs/cgi-bin/inn-i';

$file = $datafiles.'/maint.html';
open (IN, "< $file") or die "couldn't open datafile $file $!";

I think you had two problems the \ instead of / and the concentrated string in the open function.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved