I have a directory /var/spool
and inside that, directories named
a b c d e f g h i j k l m n o p q r s t u v x y z
An
As others have noted, use File::Find:
#!/usr/bin/perl
use strict;
use warnings;
use File::Find;
find(\&find_emails => '/var/spool');
sub find_emails {
return unless /\A[0-9]+[.]\z/;
return unless -f $File::Find::name;
process_an_email($File::Find::name);
return;
}
sub process_an_email {
my ($file) = @_;
print "Processing '$file'\n";
}