http://www.perlmonks.org?node_id=14132

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question: (files)

I have an application where I need to check if I file exists without actually modifying it in any way except for reading it's file name. What is the most common way of doing this?

Originally posted as a Categorized Question.

  • Comment on How do I test if I file exists without attaching a filehandle to it?

Replies are listed 'Best First'.
Re: How do I test if I file exists without attaching a filehandle to it?
by ZZamboni (Curate) on May 22, 2000 at 18:41 UTC
    Note that most file test operators imply existence when they return a true value. So -r actually means "exists and is readable", and so on. So if you are interested not only on existence, but on some other specific condition of the file, you can simply use the appropriate operator and skip -e altogether.
Re: How do I test if I file exists without attaching a filehandle to it?
by athomason (Curate) on May 22, 2000 at 07:00 UTC
Re: How do I test if I file exists without attaching a filehandle to it?
by galande (Initiate) on Nov 24, 2000 at 13:13 UTC
    Hi,
    Use operators like -e, -r, -T for testing file permissions.
    (-e <FILE/FILEHANDLE> returns true if file exists. -r <FILE/FILEHANDLE> returns true if file is readable. -T <FILE/FILEHANDLE> returns true if file is a text file.