use strict; use warnings; my $directory = '.'; for my $YMLfile (<"$directory/*.yml">) { open my $fh, '<', $YMLfile or die $!; while (<$fh>) { # process the file's contents } close $fh; }