in reply to Re: converting strings to ints
in thread converting strings to ints

And you can prevent the used only once warning, by using them twice. Eg. add a line $a = $b;.

use vars qw($a $b); will also quiet the warning.

But I don't understand why the warning should arise in the first place, especially from the use of such a common module as List::MoreUtils. The warning is not triggered by the solitary presence of  $a and  $b in the comparison block of the sort built-in. If this is an issue with List::MoreUtils and its ilk, shouldn't this be taken care of within the module somehow (but don't ask me how)?

Replies are listed 'Best First'.
Re^3: converting strings to ints
by BrowserUk (Patriarch) on Mar 20, 2010 at 21:33 UTC

    I honestly don't know for sure, but I assume that as sort is a part of the compiler, it knows what to tweak to ensure that the warning isn't produced. List::Util::reduce() also seems to take care of it. Leastwise the XS version. The PP version also causes the warning, so maybe it's not possible to do from a pure perl module.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.