opendir(my $dh, '.') or die("Unable to list directory: $!\n"); while (defined(my $file = readdir($dh))) { ... }