my @logfiles = glob "*.log"; #### while(readdir $dh) { next unless -f and /\.log$/; # Process log file here }