in reply to Read first line from each file in a directory
-
As others have mentioned, '$file' should be $file (no quotes), and check the return code of your opendir and open calls.
- You also have probably chosen a bad name for your file handle. WRITE for a read-only file handle would cause at least a double take.
- I believe that you will find that $file contains the name of the file without the directory name. You probably mean to use "$dir/$file" (for appropriate values of $dir).