The Documentation for the reduce function in List::Util suggests that the use of $a and $b in the block on line 39 is correct (and aparently intended to be "similar" to the way sort uses $a and $b) and totally unrelated to the use of $a on line#49.
I would suspect the core of your problem is that you aren't importing "reduce" when you use List::Util qw( max min ); (since the docs for List::Util suggest that it doesn't export anything by default) but fixing that doesn't seem to have any affect.
My best guess is that List::Util doesn't play nicely with blessed obejcts ... but that seems unlikely.
...oh, wait a minute. your abs() method isn't returning an object, it's returning a number. ... The first pass reduce makes will be on the first two obejcts in your list, which you've told it to call the abs() method on each, and sum the result. In the second pass $a will be the result of the first pass, and $b will be the next obect in your list ... maybe it's at that point that you get the error about not being able to call abs (because $a is just a simple scalar) ... but i would expect a slightly differnet error about it being unblessed, not about it being undefined ... hmmmmm.
In reply to Re: Can't call method "abs" on an undefined value.
by hossman
in thread Can't call method "abs" on an undefined value.
by HollyKing
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |