for my $filename (glob("*.txt")) { next if (!-f $filename); open(my $fh,"<",$filename) or die "Can't open $filename for reading"; #...process file }