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

Problem using if( -e $filename) , returns strange answers

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I'm using something like if( -e $filename) to check if a file exists or not, if it doesn't, it gets created and header information put in it.  But I'm not getting consistent results back from it.  For example, it will correctly work out that the file doesn't exist and create it/add headers, but then the next time the script is run, it says the file doesn't exist again.  I'm running ActiveState Perl and Apache under Windows.  Do you have any idea why it doesn't work correctly?  Or how about another way to check if a file exists?
 
give us a look at a snippet of code......I'm sure someone will chime in. <p> <br><a href=mailto: > </a><br><a href= > </a><br> keep the rudder amid ship and beware the odd typo
 
Code snippet of my pared down code for just trying to get it to give me sensible results was something like:

if( -e $filename)
{
print &quot;If is TRUE&quot;;
}
else
{
print &quot;If is FALSE&quot;;
}

But I don't get consistent results. The file will not exist, get one particular result, the file is created later. Run the script again (file now exists) and will get the same result as before.

 
Make sure that the place where the file is being created is the same as where you're looking to see if it exist.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top