|Welcome to the Monastery|
Re: Name "main::a" used only once: possible typo (limitations of "sort" like functions)by LanX (Bishop)
|on Mar 05, 2013 at 21:57 UTC||Need Help??|
> Why did the first example generate the warnings?
Wrong question. Since sort is a built-in, it was able to silence the warnings!
> What is the recommended way to silence them?
Use them twice?
> Why is this not mentioned in List::Util?
Maybe because the author is frustrated about not beeing able to simulate a built-in?
... it's not that easy to design functional constructs with special variables in code-blocks like sort does.
I tried it in hgrep and then I was confronted with many scoping problems, what if the block is defined within another package or if $a and $b are declared as lexicals?
Look into the code of Hash::MostUtils to have an idea about the complications to solve all of this.
I bet that List::Util couldn't solve all of this.
To prove my last guess:
This prints 55, but after uncommenting the second line its only 0 ...oops!
and here the same problem for List::MoreUtils
At least sort simply dies