my @auswahl; for my $dir (@subdirs) { push @auswahl, $dir if $dir =~ m/^hallo_00\d$/; # oder auch push @auswahl, $dir unless $dir =~ m/\.alt$/; } # oder auch my @auswahl = @dirs[0..2]; # du sagtest, die ersten 3