chdir($DIRECTORY); opendir(DIR,"$DIRECTORY"); while( my $datei = readdir(DIR) ) { open(FILE, "$datei") or die; my @status=funktionsaufruf(); close(FILE); if($status[0] =~ m/matching/) { #...mache was } } closedir(DIR);