in reply to Re^2: Which is better software design
in thread Which is better software design

Completely agree. The change in structure is a much bigger job but one worth doing (or at least considering).

Without knowing the detail of the OP's system it is hard to suggest anything specific. That said, generally the best approach IMHO to vanilla CGI is to collect, validate and sanitise the inputs right at the start so that by the time any real processing occurs the script has a known clean data set to work with. This is almost always worth the code refactoring work to achieve it and results in the rest of the code being leaner for having to do less validation at that later stage.