develooper Front page | perl.beginners | Postings from March 2002

Re: open(FILE, " ") question

Thread Previous
Agustin Rivera
March 20, 2002 13:56
Re: open(FILE, " ") question
Message ID:
It's probably because the of the file path.  Try specifying the whole path
to see if it works.

Agustin Rivera

----- Original Message -----
From: "Eric Preece" <>
To: <>
Sent: Wednesday, March 20, 2002 1:52 PM
Subject: open(FILE, " ") question


I am very new to perl. I am writing a script that is supposed to open an
html file and do some various tasks then later on it should print out the
html file. I am having problems with one portion of it. I distilled it down
to this code snippet

# test
use strict;

my $file;
my $HTML;

sub testOpen {
local (*FILE); # filehandle
$file = $_[0] || die ("No file specified\n");
open(FILE, "$file") || die("File could not be opened - $file\n");
while (<FILE>) {
$HTML .= $_;
$HTML =~ s/\$(\w+)/${$1}/g;
return $HTML;

print "Content-type: text/html\n\n";
print &testOpen("test.htm"); # Prints the contents of this file


My problem is this works great from the command prompt. But will not open
the file if hit the script from a browser. I am not sure why it behaves
differently in a browser - I suspect permissions but I have the directory
set to write, execute.

I am using a win2k IIS box with the lastest version of ActivePerl.

Thanks in advance,


Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About