table of contents
| MIME::Type(3) | User Contributed Perl Documentation | MIME::Type(3) |
NAME¶
MIME::Type - Definition of one MIME type
SYNOPSIS¶
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'
DESCRIPTION¶
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
OVERLOADED¶
overload: string comparison
overload: stringification
example: use of stringification
my $mime = MIME::Type->new('text/html');
print "$mime\n"; # explicit stringification
print $mime; # implicit stringification
METHODS¶
Initiation¶
MIME::Type->new(OPTIONS)
Option --Default encoding <depends on type> extensions [] simplified <derived from type> system undef type <required>
. encoding => '7bit'|'8bit'|'base64'|'quoted-printable'
. extensions => REF-ARRAY
. simplified => STRING
. system => REGEX
. type => STRING
Attributes¶
$obj->encoding
$obj->extensions
$obj->simplified([STRING])
MIME::Type->simplified([STRING])
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'
$obj->system
$obj->type
Knowledge¶
$obj->equals(STRING|MIME)
$obj->isAscii
$obj->isBinary
$obj->isRegistered
$obj->isSignature
$obj->mediaType
For historical reasons, the 'mainType' method still can be used to retreive the same value. However, that method is deprecated.
$obj->subType
DIAGNOSTICS¶
Error: Type parameter is obligatory.
SEE ALSO¶
This module is part of MIME-Types distribution version 1.28, built on September 07, 2009. Website: http://perl.overmeer.net/mimetypes/
LICENSE¶
Copyrights 1999,2001-2009 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
| 2009-09-06 | perl v5.10.1 |