in reply to Downloading things from a database
You can actually get away with not knowing the content-type, you just default to application/octet-stream. Give the following a try, it is very nice. All you will need to do is perform a length() on the data and give a filename.
use CGI; my $size = length ($blob); my $filename = 'good_data.txt'; print CGI::header( -Content-Disposition => "attachment; filename=$filename", -Content-Type => 'application/octet-stream', -Content-Length => $size, -Pragma => 'no-cache', -Expires => 0 ); print $blob;