small nit, but rather than using `lc` in several places, why not just use it once here?

```perl
my $query = lc $_;
```