Welcome to the Monastery | |
PerlMonks |
Re: Name "main::a" used only once: possible typo (limitations of "sort" like functions)by LanX (Saint) |
on Mar 05, 2013 at 21:57 UTC ( [id://1021906]=note: print w/replies, xml ) | Need Help?? |
Hi Gabor > 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? Seriously ... ... 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.
UPDATETo prove my last guess: This prints 55, but after uncommenting the second line its only 0 ...oops!
UPDATEand here the same problem for List::MoreUtils
UPDATEAt least sort simply dies
Update...but
Cheers Rolf
In Section
Seekers of Perl Wisdom
|
|