So a scan your post suggests you would be well served by using strict
in your coding -- see Basic debugging checklist
and Use strict warnings and diagnostics or die
. If I'm reading it correctly, most of your return statements return barewords rather than strings. For example, I expect return K;
should actually be return 'K';
-- you don't actually have a subroutine named K, right?
Of course, all this is guesses because your posted code is mangled because of lack of <code> tags and you don't provide input or expected output. See How do I post a question effectively?
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.