in reply to Cannot open file within a loop

What directory is $file in? is it the same one that $dir is in?

If you're planning to filetest the return values out of a readdir, you'd better prepend the directory in question. Otherwise, because we didn't chdir there, it would have been testing the wrong file.
http://perldoc.perl.org/functions/readdir.html

Replies are listed 'Best First'.
Re^2: Cannot open file within a loop
by ic23oluk (Sexton) on Jun 14, 2017 at 07:10 UTC

    $file is in $dir
    but the error message spits out 'sequence.fa which is the correct name

      it is the correct name if you were in $dir, but you are not, you are in the directory that contains $dir arnt you?

      So from the directory containing dir, what is the correct name for the file

        thanks a lot !! I just added $dir to $file and it worked :)