in reply to Premature End of Script Headers

The most obvious thing to me is that you have quite a lot of redundancy in there. use warnings does everything -w does, plus some (I recall hearing that some people consider -w to be broken, but I don't remember the reasons behind this). Also, you don't need to put two use CGI lines in there--all you need is the one that has the qw(:standard).

Not sure if this will actually fix your problem, but its a start.

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

Note: All code is untested, unless otherwise stated