use MIME::Types; my $mimetypes = MIME::Types->new; my MIME::Type $plaintext = $mimetypes->type('text/plain'); print $plaintext->mediaType; # text print $plaintext->subType; # plain my @ext = $plaintext->extensions; print "@ext" # txt asc c cc h hh cpp print $plaintext->encoding # 8bit if($plaintext->isBinary) # false if($plaintext->isAscii) # true if($plaintext->equals('text/plain') {...} if($plaintext eq 'text/plain') # same print MIME::Type->simplified('x-appl/x-zip') # 'appl/zip'
MIME types are used in MIME entities, for instance as part of e-mail
and HTTP traffic. Sometimes real knowledge about a mime-type is need.
Objects of MIME::Type
store the information on one such type.
This module is built to conform to the MIME types of RFC's 2045 and 2231. It follows the official IANA registry at http://www.iana.org/assignments/media-types/ and the collection kept at http://www.ltsw.se/knbase/internet/mime.htp