Hi List,

This is probably a really simple question, but I need some help with this.
Basically, I am searching through a directory and if something matches what I am looking for, then save that filename to a text file. Something like this:
===================================
$wanted_filename='thisfilename';


opendir (DIRECTORY, "/directory/");
        @filenames=readdir(DIRECTORY);
closedir(DIRECTORY);

for ($i=0; $i <= $#filenames; $i++) {
        [EMAIL PROTECTED];
        if ($wanted_filename == $filename) {
                $append_filename=$filename . ';';
                open(APPENDFILE, ">>/anotherdirectory/filename.txt");
                        print APPENDFILE $append_filename;
                close(APPENDFILE);
        }
}
====================================

But for some reason, the IF statement did not work. In the filename.txt file, I am getting something like this:

.;..;file1;file2;thisfilename;file3;.....

Basically the IF statement did not filter out the files that I didn't want. The only filename that I wanted to store, if it's found in the directory, is "thisfilename". Any help is appreciated. Thanks.

John



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to