Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Opening an empty file hangs it up (Read 1319 times)
Imp_In_Training
God Member
*****
Offline


Don't follow me, I'm lost
too!

Posts: 608
Location: Aberdeen
Joined: Jun 17th, 2004
Gender: Male
Opening an empty file hangs it up
Mar 23rd, 2013 at 12:50pm
Print Post  
I have this subroutine that has been hanging up if the file 'dicelog.txt' is empty.  So I added this little check to throw at least one line of text in the file before running the rest of it.  But it's still hanging up.

Code
Select All
	if (!-s "$vardir/dicelog.txt")  {
		fopen(ROLLLOG, ">>$vardir/dicelog.txt") || die "$RollLog{'1'} $!";
		print ROLLLOG "<tr><td>";
		print ROLLLOG localtime;
		print ROLLLOG "</td><td>System</td> <td> NA </td> <td> NA </td> <td> NA </td> <td> NA </td> <td> New Roll Log Created </td> </tr>

\n";
		fclose(ROLLLOG);

	} 



Is this hanging up because of the way I'm checking for an empty file, or is there some other reason?

Is it possible that I need to add a pause just to allow the process time to create the file before it tries to open it?
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint