![]() |
|
Don't ask to ask, just ask | |
PerlMonks |
Re: OO base class lookup failingby Somni (Friar) |
on Oct 16, 2007 at 03:24 UTC ( [id://645106]=note: print w/replies, xml ) | Need Help?? |
This is what I meant by reducing the code to the minimum necessary to exhibit the problem:
This was accomplished by cutting out whole swathes of code, then running the program to verify the error was still apparent. If it was, continue cutting, if it wasn't back off some of the edits and try again. This can be a valuable technique if you truly don't understand what's going on. What I discovered is that the subroutine reference, \&_field_one, was important. Removal of that would make the error go away. Tk wasn't even involved, and could be removed from the equation entirely. In fact, the code can be reduced even further:
The problem is, apparently, that when you take a reference to a subroutine that did not already exist the symbol table is updated. This causes a method lookup to find a Foo::frob subroutine, but there is no actual code for this subroutine, so the method call ultimately fails. The simple solution is, don't take references to subroutines that don't exist in your local namespace. You take a reference to THREE::_field_one and store it in @single_key_functions, but there is no such subroutine. This was an error on your part, I suspect. Incidentally, had you gone over to using strings (i.e. $func = "_space"; $s->$func($key_event, $key_code)) as I originally suggested this error would have disappeared, as you would have removed the \&_field_one from @single_key_functions.
In Section
Seekers of Perl Wisdom
|
|