if ($file =~ /\.txt\z/) { print("Match\n"); } else { print("No match\n"); }