MIME::Type - Definition of one MIME type
use MIME::Types; my $mimetypes = MIME::Types->new; my MIME::Type $plaintext = $mimetype->type('text/plain'); print $plaintext->mediaType; # text print $plaintext->subType; # plain
my @ext = $plaintext->extensions; print "@ext" # asc txt c cc h hh cpp
print $plaintext->encoding # 8bit if($plaintext->isBinary) # false if($plaintext->isAscii) # true
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 collection kept at http://www.ltsw.se/knbase/internet/mime.htp
MIME::Type
object which manages one mime type.
OPTION DEFAULT type <obligatory> simplified <derived from type> extensions undef encoding <depends on type> system undef
x-
, to indicate
that is a non-registered name. Of course, after registration this flag
can disappear which adds to the confusion. The simplified string has the
x-
thingies removed and are translated to lower-case.
text/
will default
to quoted-printable
and all other to base64
.
$^O
.
'text/plain'
x-
preamble to indicate that. Of course, after recognition,
the x-
can disappear. In many cases, we prefer the simplified version
of the type.
Examples:
my $mime = MIME::Type->new(type => 'x-appl/x-zip'); print $mime->simplified; # 'appl/zip' print $mime->simplified('text/plain'); # 'text/plain' print MIME::Type->simplified('x-xyz/x-abc'); # 'xyz/abc'
'text/plain'
it will return 'text'
.
For historical reasons, the 'mainType'
method still can be used
to retreive the same value. However, that method is deprecated.
'text/plain'
it will return 'plain'
.
x-
. This counts for as well the media-type as the
sub-type. In case either one of the types starts with x-
this
method will return false.
Mark Overmeer (mimetypes@overmeer.net). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
This code is beta version 0.16.
Copyright (c) 2001 Mark Overmeer. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.