|go ahead... be a heretic|
Re: using grep on a directory to list files for a single dateby zejames (Hermit)
|on Dec 01, 2004 at 13:43 UTC||Need Help??|
Just for fun, I wanted to measure the speed difference of greping and just using while.
So I created, in a test directory, lots of small files :
Then I tried to list each file of this directory, and compare :</o>
As expected, the difference is huge :
Using grep, perl interprets readdir in list context, and builds and return the whole list of files of the directory, that is huge.
When using while, perl returnes file names each by each, which is much cheaper in memory.
So, in your case : use while.
For information, I was using Windows XP SP1 and ActivePerl 5.8.4 on a NTFS file system.