use File::Find; my @dir_list; sub wanted { if( -d $_ ) { push @dir_list, $File::Find::name; } } find( &wanted, '.' ); # @dir_list now contains the list of directories found. #### use File::Find; sub process_each_file { if( file_is_interesting($File::Find::name) ) { my $parsed_content = parse_file($File::Find::name); unless( content_is_boring($parsed_content) ) { my $sucess = insert_into_database($parsed_content); $log->error("problem") unless $sucess; } } } find( &process_each_file, '.' ); # All files have now been read & relevant stuff is in the database.