use strict; use File::MimeInfo; # ...get $location from DB.... my $mtype = mimetype($location); open my $fh, $location or die "Could not open $location: $!"; print "Content-type: $mtype\n\n"; print while <$fh>;