given/when and lexical $_ ...
... or happy debugging!
TL;DR Upd: Use for instead of given, as Aristotle suggests.
Here are some code snippets to show what's wrong with given/when.
use 5.010;
use strict;
use List::MoreUtils qw/any/;
given ('test') {
when ('test') {
say "any" if any {$_ == 2} (2, 3);
}
}
The above code prints nothing. Ok, let's change any to grep to see if it works: