my @dirs; my @files; for (readdir DIR) { next if $_ eq "." or $_ eq ".."; if (-d "$base/$_") { push @dirs, $_; } else { push @files, $_; } }