Also, should you decide to use the quantifiers in the actual regex rather than through a variable being interpolated, don't forget to escape the quantifiers:
my $file =~ /\.txt$/;
This regex ensures that the txt falls at the end of the filename and is preceded by a '.'.