I just ran your code and it worked for me except I added an "opendir" as well:
opendir DIR, '.' or die "Cannot open current dir. $!";
my @files = grep { /\.(?:dat)$/i } readdir DIR;
closedir DIR;
my $datfile = $files[0];
print "\$datfile ==> $datfile\n";