@files = readdir(DIR);
to
my @files = grep( /\.dat$/, readdir(DIR));
grep in this case will return all the elements of the list returned by readdir that end with a ".dat".
BTW:Athough this has nothing to do with your question, I would recommend always adding use strict; to the top of your scripts. strict will catch a lot of tricky errors.
----
Coyote
In reply to Re: filtering file names to be added to an array...maybe.
by Coyote
in thread filtering file names to be added to an array...maybe.
by udigthis
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |