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!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.