http://www.perlmonks.org?node_id=159552


in reply to DBI script runs from command line, not from CGI

I don't see any exception handling in the DBI calls (prepare, execute). try adding something like:
$sth->execute($i, $data{$i}{cname}, $j, $data{$i}{ports}{$j}{service}, + $data{$i}{ports}{$j}{banner}) or die "Content-type: text/plain\n\n $ +DBI::errstr";
(the prepare is also an excellent candidate as well)