Home: Need a Custom or Prewritten Perl Program?: I need a program that...:
Finding a File inside a Directory



cbwery2
Deleted

Sep 13, 2000, 1:52 PM


Views: 1987
Finding a File inside a Directory

I need to check if a file exist inside
a directory. For example

I want to check if the file video.mpg
does exist in /usr/src/images

Someone gave me an idea of put all
the files in an array and then search
inside the array.


Kanji
User / Moderator

Sep 13, 2000, 3:48 PM


Views: 1987
Re: Finding a File inside a Directory

No need for an array: just use a file test operator such as the one for (whoa!) file existence!

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

if ( -e "/usr/src/images/video.mpg" ) {
print "It does";
} else {
print "It doesn't";
}</pre><HR></BLOCKQUOTE>