in reply to Question: File name pattern match using Grep function

alternatively use
my $file_mask='\.txt';
to avoid interpretation of the '\'. Please note the different quotes.