For starters, do you have strict and warnings enabled? You should always be using those.
If you could post some code (always the best thing to do!) then we might be able to help more. Also, why not output your debug statements to a file, so you can read what happens just before it crashes?