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

Problem with writing to FILE----What am I missing? 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0

The file is created but never written to.
Here is the code. Should I be doing this different.

Thanks
----------------------------------------------------

$filename = "update.txt";

open(FILE, ">$filename") # open for update
or die "Can't open".$filename." for update: $!";
while (<$filename>){
print &quot;Content-type: text/html \n\n&quot;;
print &quot;<HTML>&quot;;
print &quot;<HEAD><TITLE>Staff</TITLE>&quot;;
print &quot;<BODY BGcolor='#FFFFFF'>&quot;;
}
close(FILE);


 
You shouldn'be be using the while(<$filename>) construct, that's for reading the file. Also, you should be using print FILE &quot;whatever&quot;; to print to the file. You could also do this:
Code:
print FILE <<END;
Content-type: text/html

<HTML>
<HEAD>><TITLE>Staff</TITLE>
<BODY BGcolor='#FFFFFF'>
...
END

Note that there is no semicolon on the END line and it MUST start in column 1. Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top