MIME::Type - description of one MIME type |
MIME::Type - description of one MIME type
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.
example: use of stringification
my $mime = MIME::Type->new('text/html'); print "$mime\n"; # explicit stringification print $mime; # implicit stringification
-Option --Default encoding <depends on type> extensions [] simplified <derived from type> system undef type <required>
text/
will default
to quoted-printable
and all other to base64
.
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.
$^O
.
x-
preamble to indicate that. Of course, after recognition,
the x-
can disappear. In many cases, we prefer the simplified version
of the type.
example: results of simplified()
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'
true
when the type is defined for experimental
use; the subtype starts with x.
true
when the type is defined by a person for
private use; the subtype starts with prs.
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.
true
when the type is defined by a vendor; the subtype
starts with vnd.
'text/plain'
it will return 'text'
.
For historical reasons, the 'mainType'
method still can be used
to retrieve the same value. However, that method is deprecated.
'text/plain'
it will return 'plain'
.
type
option flag.
This module is part of MIME-Types distribution version 2.12, built on November 11, 2015. Website: http://perl.overmeer.net/mimetypes/
Copyrights 1999,2001-2015 by [Mark Overmeer]. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html
MIME::Type - description of one MIME type |