opendir(DIR,'.'); @all_logs = grep /\.log$/, readdir(DIR); for my $log (@all_logs) { # some processing }