I haven't tried DogFish's method, but for thinner pieces I've had good results with a thin, very sharp knife.
For thicker pieces, I've compressed the foam between two boards (if they are two narrow, the edge will be funny), and then using a thin, sharp blade.
I've also heard of (but not tried myself) of people soaking the foam in water and freezing it, and then drilling into it (to make a foam prefilter or something similar).
I have used an electric knife for cutting foam before it works well. I have also just used a regular knife and a pair of sizzlers and had decent luck.