use IO::Dir; my $count = 0; my $dir = IO::Dir->new(".") or die; $count++ while $dir->read;