Steve, you're code is definitely cleaner to look at, but I'm curious what problems you had running it the original. I copied it verbatim from the HTML, deleted the non-code, and ran it. I got two messages, one from the lone &msg(400), the other from the true if(), since $proto is undefined (no use strict and no -w. *gasp*).
I then defined $proto with "HTTP/1.0", and got only one message, since the if() failed.
What problems were you running into?
--Chris
e-mail jcwren