my $dir = './new_text'; opendir my $dh, $dir; my @files = grep { -f } map { "$dir/$_" } readdir $dh; closedir $dh;