How do I prevent List::MoreUtils from warning about using $a and $b only once?

前端 未结 6 1773
温柔的废话
温柔的废话 2020-12-15 06:08

The List::MoreUtils module indicates that you use the variables $a and $b when supplying the BLOCK that goes with the pairwise

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-15 06:15

    I have the same problem with a similar module I'm writing. The only solution I've found (other than using functions that use $a and $b twice, of course) is to put this line somewhere in your code:

    $a = $b; # hack to disable warnings about "main::a" used only once
    

    It basically does nothing, but it does disable the warning. Consider keeping the comment so future maintainers don't have to read your mind.

提交回复
热议问题