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

Beats me, but you can use $::_ to refer to the global $_

Replies are listed 'Best First'.
Re^2: Lexical $_ in given/when vs. BLOCK arguments
by Anonymous Monk on Oct 25, 2011 at 10:00 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 $_;

      or even any { our $_; ... }