Parse a mime content-type header
version 1.017
use Email::MIME::ContentType; # Content-Type: text/plain; charset="us-ascii"; format=flowed my $ct = 'text/plain; charset="us-ascii"; format=flowed'; my $data = parse_content_type($ct); $data = { type => "text", subtype => "plain", attributes => { charset => "us-ascii", format => "flowed" } };
This routine is exported by default.
This routine parses email content type headers according to section 5.1 of \s-1RFC\s0 2045. It returns a hash as above, with entries for the type, the subtype, and a hash of attributes.
For backward compatibility with a really unfortunate misunderstanding of \s-1RFC\s0 2045 by the early implementors of this module, \*(C`discrete\*(C' and \*(C`composite\*(C' are also present in the returned hashref, with the values of \*(C`type\*(C' and \*(C`subtype\*(C' respectively.
This is not a valid content-type header, according to both \s-1RFC\s0 1521 and \s-1RFC\s0 2045:
Content-Type: type/subtype;
If a semicolon appears, a parameter must. \*(C`parse_content_type\*(C' will carp if it encounters a header of this type, but you can suppress this by setting $Email::MIME::ContentType::STRICT_PARAMS to a false value. Please consider localizing this assignment!
Simon Cozens <[email protected]>
Casey West <[email protected]>
Ricardo \s-1SIGNES\s0 <[email protected]>
This software is copyright (c) 2004 by Simon Cozens.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.