in reply to Parsing /etc/mime.types into something usable

Of course if LWP is installed there's always the LWP::MediaTypes module and its guess_media_type function.