Not very elegant, but:
$filecount = 0;
@filesindir = `ls /home/a/*.txt`;
foreach $file (@filesindir) {
$filecount++;
}
print "The number of text files in my directory is: $filecount\n";
Comment on Re: how to get total numbers of files in a directory?