if (opendir(SEARCH, $path) && open(DATA,">$database")) { while (defined ($search = readdir(SEARCH))) { next if $search =~ /^\.\.?$/; if (!($search =~ /.xml|.txt|.zip|include/)) { print (DATA "$search\n"); } } closedir SEARCH ; }