http://www.perlmonks.org?node_id=705516


in reply to Avoiding silly programming mistakes

Being a beginner myself, I know what you mean. I am unable to write two statements in a row without making one mistake. The best way that I found to come around this is by writing code in small chunks and testing them in isolation.
So I will normally have two open buffers; in the first one I am writing the actual script and in the second one I test the current working paragraph. This way, spelling mistakes and bugs are caught earlier, and I seldom have to hunt them down too much.

Of course there is also the case that other bugs arise when this "code chunks" interact poorly, but most of the "d'oh" mistakes become evident earlier this way.