in reply to Spitting out a webpage

Try using HTTP::Response to construct your HTTP responses.

Even if you're just doing this as a learning exercise, you can read the source of HTTP::Response to get a better idea.

-David