From: sureone on
Could anybody give a sample code for this question?

Thanks!

From: John W. Krahn on
sureone(a)gmail.com wrote:
> Could anybody give a sample code for this question?

if ( -e 'filename' ) {
print "'filename' exists.\n";
}


perldoc -f -e
perldoc -f stat


John
--
use Perl;
program
fulfillment
From: Samwyse on
John W. Krahn wrote:
> sureone(a)gmail.com wrote:
>
>>Could anybody give a sample code for this question?
>
> if ( -e 'filename' ) {
> print "'filename' exists.\n";
> }


John, John, John. *sigh* You didn't answer his question. You should
have said, "Yes", and then given the perldoc references.
From: Juha Laiho on
"John W. Krahn" <krahnj(a)telus.net> said:
>sureone(a)gmail.com wrote:
>> Could anybody give a sample code for this question?
>
>if ( -e 'filename' ) {
> print "'filename' exists.\n";
> }

However, be careful if later on performing any action based on the
knowledge that at some point in the history the file did exist.

Most often, one is interested, whether a piece of data can be read
from a file - and in this context it'd be better to attempt to
open the file and read the data. Just encapsulate the functionality
performing this to allow an upper level to process and report the
error appropriately.
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)