my $directory = '...'; opendir my $DIR, $directory or die $!; my @files = grep /\.dat$/i && -f, map "$directory/$_", readdir $DIR;