in reply to Doubt about Template Toolkit
I just noticed that your template is a complete HTML page (with two <head> tags, btw). So, you are printing two complete HTML pages to STDOUT. Your browser will read until the first </html> and then do the refresh. What behavior do you expect from that application?
In Section Seekers of Perl Wisdom