johnnyfolk covered most of it, but I'd like to point out Template Toolkit if you want to use a very powerful templating system. I use it just about whenever I need to template anything, and it works great.
If you ever work in a team, or have someone else doing the web design work, you will want (and need) to seperate the code from the presentation.