in reply to Re^2: I need help with opening a directory and reading files in that directory.
in thread I need help with opening a directory and reading files in that directory.

opendir DH, "Y://perlscripts2/software/perl2/music" or die $!; while($_ = readdir(DH)){ ... if (-f $_) {

The file test will work when the value being tested is a path which can be accessed from the current directory where the program was started. As is, $_ contains only the bare file name, devoid of directory name.

open FH, "<$_" or die $!; print "output for file: $_\n"; while (my $line = <FH>) { ... if ($line =~ /\.txt/){ ... } close FH; }

A closure of the file handle while still iterating over it will result in "readline() on closed filehandle" (perl 5.16.2) error message, causing premature demise of the program. If the file handle needs to be closed early, then should skip the whole loop via last.