I'm not sure of your exact error, here, because it's
very hard to see what's in the @data array (use
<code> tags!).
But you're printing out the header twice... did you see
that? First you print it out by hand, then you print it
out using CGI::header. Take one of those out. Also check
to see that @data has what you think it should.