my $txt='txt'; opendir my $d,'.' or die "Can't opendir .: $!"; my @files=grep /\Q$txt\E$/,readdir $d; closedir $d;