# this is the line I removed # ($file) = grep {-f $_ and not -l $_} map File::Spec->catfile($root, $_), readdir FH; # and replaced with this foreach my $x (readdir(FH)) { my $y = File::Spec->catfile($root, $x); if (-f $y && ! -l $y) { $file = $y; last; } }