×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

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

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

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

(OP)
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?

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

give us a look at a snippet of code......I'm sure someone will chime in.




keep the rudder amid ship and beware the odd typo

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

(OP)
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 "If is TRUE";
}
else
{
   print "If is FALSE";
}

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.

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

Make sure that the place where the file is being created is the same as where you're looking to see if it exist.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close