There's more than one way to do things | |
PerlMonks |
Re: filtering file names to be added to an array...maybe.by Coyote (Deacon) |
on Jun 06, 2001 at 09:21 UTC ( [id://86124]=note: print w/replies, xml ) | Need Help?? |
Change the line @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.
----
In Section
Seekers of Perl Wisdom
|
|