I think corporal punishment does work to a certain extent, but not as much as many of you think it does.
If the kid realize that you are purposely not trying to hurt them and only intent is to give them pain to stop the behavior then it becomes useless altogether. In that situation the kid mindset would be "I'll get in trouble, but it's only a little bit pain and nothing worst than that".
I do think things like "time-out" are generally useless and modern parents are too soft on their children. There are many effective way to deter or encourage a behavior.
For example, i currently go and visit my niece and nephew once a week. My niece has a terrible habit of biting her fingernails, but i generally got her to stop it by associating not biting her fingernails with getting a treat every time i come over. Also if you're having trouble coming up with punishment, foods generally works really well. My nephew hates broccoli, so my brother would always make some when he does something bad. One of us would then stand over him and make him finish every bit of it before he can go do anything else. I believe the key is to make the punishment as unpleasant as possible, and that doesn't necessarily mean it has to hurt physically.
There are always exception to the rule though and there have been enough cases of criminals coming from perfectly functional family to prove that.