What do you mean by "something is still wrong"? Do you mean that it's not in the format you want? If you want to output HTML, replace the entire second part with something like
print header;
if ( keys %data ) {
# found, display data
print ul( map { li("$_: $data{$_}") } keys %data);
}
else {
# not found, show error
print h1("Can't find row '$rowid'");
}
The functions header, ul, li and h1 are all in CGI.pm (and do just what they sound like.) Ideally you'd want to use something like Template Toolkit or Text::Template for you html, rather than embedding it in the perl.