HTML::Template has a documented print_to option for the output() method that streams exactly like you're describing. And, HTML::Template is poorly named - I use it for a lot more than just HTML. If I was outputting XML, I would use and have used H::T.