Ahh, now I see what you're trying to do...
Remember when we warned things could get hairy? OK, firstly - please consider what Anonymous Monk said very carefully..
OK, now that we know what your files look like, lets focus on why we're not opening/processing them. 2 things:
- Are the files being tested accessible to the script? i.e. does the script live in the same directory as they do? Y://perlscripts2/software/perl2/music. If it doesn't - you'll need to consider how to supply your if (-f ...) conditional with the absolute path to the file you're testing OR change directory to the same directory as the files you're testing prior to testing them (see chdir)
- Once you've addressed the incorrectly placed close FH function call - mentioned by Anonymous Monk above (i.e. move it out of your while loop so you don't close a filehandle while working with it), I'd like you to reassess where you'd planned to put the if (/\.txt$/) conditional. hint: should we be testing a file after opening it?
Have another crack at it and see what you come up with. Larry Wall said that Perl is an empirical science - you learn things about it by trying it out.
Keep up the good work!