Well, they only hurt him when his mouth is open. There are two ways I beat him. If you are using Luigi, then jump on the platfoms above you and then you can be able to jump behind him and throw a vegetable when he opens his mouth. If you're not using Luigi then when he's about to open his mouth jump up in front of him and throw it. After several hits he will finally die.