in reply to Pattern mattching

Sure, I'll advice. I advice that you let people know what you've tried, how the results differed from what you expected, and how you tried to fix that. Only after that will I give you any more advise.

I will, however, mention one thing which is not related to your problem but which you should be aware of. The $a and $b variables are special, and should not be used unless you really mean to use them. Which you don't. So don't.