OTOH, CGI.pm has a lot of commands for writing tables and other HTML, so a lot of people including me must be mixing their program logic and their HTML in the same file.
What if the structure of the HTML depends upon the program logic? I may for instance show data as a table if more than one row is returned, but as a paragraph otherwise.
I do not believe that it is necessarily better to use templates. Merlyn has an entire chapter on CGI.pm in the 2nd version of Learning Perl, and I don't recall him giving such advice.