#!/usr/bin/perl use warnings; use strict; my $path = '/Users/Maxi/Desktop/Verzeichnis beispiel'; opendir my $DIR, $path or die " the directory couldn't be opened\n"; my @folder = grep -f "$path/$_", readdir $DIR; for my $file (@folder) { open my $FIL ,'<', "$path/$file" or die "the file $file couldn't be opened: $!\n"; while (<$FIL>) { print if /perl/i; } }