in reply to
Re: Re: Passing subroutines as arguments
in thread Passing subroutines as arguments
Read perldiag for an explanation of the error message; the error message does not lie, you're attempting to compare values, at least one of which is undefined. There's only one comparison in the code you post, so assuming that's the "offending" line, the problem is that one of $a and $b is not initialized in the call to sum. Why that would be so depends on how that subroutine came to be called, and if you look at the else clause of your conditional in the sum subroutine, you'll see the problem; what you pass to the call to sum there are three things: $term, and the results of calling the sub it points to on $a and $b. Yet your subroutine's ... ummm... signature calls for there to be four objects, so the result is that when that recursive call is made, $b is undefined.
If not P, what? Q maybe?