opendir DIR, "./" or die "Can't open: $!"; my @files = grep { /\.txt\z/ } readdir DIR; closedir DIR;