That much looks okay. You might move the print "Content-Type: text/html\n\n"; line to before the Cart::cgiparse() call. (It may print its own headers, screwing things up.)
Otherwise, you'll have to check the server configuration. That's probably beyond the scope of Perl Monks.