in reply to Re: Lexical $_ in given/when vs. BLOCK arguments
in thread Lexical $_ in given/when vs. BLOCK arguments

And its a known bug Bug #46754 for List-MoreUtils: any() attaches to the wrong $_ inside a given(){ when(){ }}

You can also use our $_; any ...

Replies are listed 'Best First'.
Re^3: Lexical $_ in given/when vs. BLOCK arguments
by Anonymous Monk on Oct 25, 2011 at 10:17 UTC

    The old standby local $_; will fail with

    Can't localize lexical variable $_ at junk line 13. (#1) (F) You used local on a variable name that was previously declared + as a lexical variable using "my" or "state". This is not allowed. If +you want to localize a package variable of the same name, qualify it with the package name.

    I think local $_ should just work, for those who can't remember to use our $_;

    At a minimum, I think the perldiag entry for this error should say to use our $_;

Re^3: Lexical $_ in given/when vs. BLOCK arguments
by Anonymous Monk on Oct 25, 2011 at 10:03 UTC
    or even any { our $_; ... }