use File::Spec; my $path=File::Spec->catfile(qw( path to file),"*.txt"); my @files=glob($path);