PERL count files in a dir

Hi Guys,

I need to count files in a dir which were updated yesterday.
ls -lth | grep -i 'Jul 7' | wc -l

The dir holds files of last 15 days and total count is as 2067476.
Is it efficient to count the files using perl? I have developed the following perl script making use of system().

Can anybody coment, any other way without using system()


#!/usr/bin/perl 
  
 
@months = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec); 
($sec,$min,$hour,$monthday,$mon,$year,$wday,$yday,$isdst) = localtime(time); 
  
  
$month =$months[$mon]; 
 
############################################# 
# ls -lth | grep -i 'Jul 7' | wc -l  
############################################# 
 
$command = "ls -lth  | grep -i '" . $month . "  " . $monthday -1 . "' | wc -l"; 
  
$count = system($command); 
print "$count \n";

Thank you
Regards
@Asteroid

I would avoid at any price to call system from a perl script.
Here's a quick try

perl -e 'opendir (DIR, $ARGV[0]) ; @count = readdir(DIR); $count = @count; print $count-2,"\n"' /path/to/your/directory

---------- Post updated at 11:27 ---------- Previous update was at 11:25 ----------

Edit: added the -2 in order not to count "." and ".."

Thx blitzer for the reply, what if I want to count files updated ona specfic date.
I mean, I don't want to count all the files in the directory. I want to count files updated/created on a specfic date (say today 08-07-2009).

An equivalent in bash is some thing like this:

ls -lth | grep 'Jul  8' | wc -l

This is how I can count files, updated on 8th july 2009 (using bash)

Thank you.

Your question has been answered on another forum