{
    "mode": "perldoc",
    "parameter": "Mail::Message::Field::Attribute",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Mail%3A%3AMessage%3A%3AField%3A%3AAttribute/json",
    "generated": "2026-06-09T15:55:40Z",
    "synopsis": "my $field    = $msg->head->get('Content-Disposition') or return;\nmy $full     = $field->study;   # full understanding in unicode\nmy $filename = $full->attribute('filename')           or return;\nprint ref $filename;     # this class name\nprint $filename;         # the attributes content in utf-8\nprint $filename->value;  # same\nprint $filename->string; # print string as was found in the file\n$filename->print(\\*OUT); # print as was found in the file",
    "sections": {
        "NAME": {
            "content": "Mail::Message::Field::Attribute - one attribute of a full field\n",
            "subsections": []
        },
        "INHERITANCE": {
            "content": "Mail::Message::Field::Attribute\nis a Mail::Reporter\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "my $field    = $msg->head->get('Content-Disposition') or return;\nmy $full     = $field->study;   # full understanding in unicode\nmy $filename = $full->attribute('filename')           or return;\n\nprint ref $filename;     # this class name\nprint $filename;         # the attributes content in utf-8\nprint $filename->value;  # same\nprint $filename->string; # print string as was found in the file\n$filename->print(\\*OUT); # print as was found in the file\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Attributes within MIME fields can be quite complex, and therefore be slow and consumes a lot of\nmemory. The Mail::Message::Field::Fast and Mail::Message::Field::Flex simplify them the\nattributes a lot, which may result in erroneous behavior in rare cases. With the increase of\nnon-western languages on Internet, the need for the complex headers becomes more and more in\ndemand.\n\nA \"Mail::Message::Field::Attribute\" can be found in any structured Mail::Message::Field::Full\nheader field.\n\nExtends \"DESCRIPTION\" in Mail::Reporter.\n",
            "subsections": []
        },
        "OVERLOADED": {
            "content": "overload: comparison\nWhen the second argument is a field, then both attribute name (case-sensitive) and the\ndecoded value must be the same. Otherwise, the value is compared.\n\noverload: stringification\nReturns the decoded content of the attribute.\n",
            "subsections": []
        },
        "METHODS": {
            "content": "Extends \"METHODS\" in Mail::Reporter.\n",
            "subsections": [
                {
                    "name": "Constructors",
                    "content": "Extends \"Constructors\" in Mail::Reporter.\n\nMail::Message::Field::Attribute->new( <$name, [$value] | STRING>, %options )\nCreate a new attribute $name with the optional $value. If no $value is specified, the first\nargument of this method is inspected for an equals sign '='. If that character is present,\nthe argument is taken as STRING, containing a preformatted attribute which is processed.\nOtherwise, the argument is taken as name without $value: set the value later with value().\n\nWhether encoding takes place depends on the %options and the existence of non-ascii\ncharacters in the $value. The $name can only contain ascii characters, hence is never\nencoded.\n\nTo speed things up, attributes are not derived from the Mail::Reporter base-class.\n\n-Option           --Defined in     --Default\ncharset                             'us-ascii'\nlanguage                            undef\nlog                Mail::Reporter   'WARNINGS'\ntrace              Mail::Reporter   'WARNINGS'\nusecontinuations                   <true>\n\ncharset => STRING\nThe $value is translated from utf-8 (Perl internal) to this character set, and the\nresulting string is encoded if required. \"us-ascii\" is the normal encoding for e-mail.\nValid character sets can be found with Encode::encodings(':all').\n\nlanguage => STRING\nRFC2231 adds the possibility to specify a language with the field. When no language is\nspecified, none is included in the encoding. Valid language names are defined by RFC2130.\nThis module has only limited support for this feature.\n\nlog => LEVEL\ntrace => LEVEL\nusecontinuations => BOOLEAN\nContinuations are used to break-up long parameters into pieces which are no longer than 76\ncharacters. Encodings are specified in RFC2231, but not supported by some Mail User\nAgents.\n\nexample:\n\nmy $fn    = Mail::Message::Field::Attribute\n->new(filename => 'xyz');\n\nmy $fattr = 'Mail::Message::Field::Attribute';  # abbrev\nmy $fn    = $fattr->new\n( filename => \"Re\\xC7u\"\n, charset  => 'iso-8859-15'\n, language => 'nl-BE'\n);\nprint $fn;\n# -->  filename*=iso-8859-15'nl-BE'Re%C7u\n"
                },
                {
                    "name": "Error handling",
                    "content": "Extends \"Error handling\" in Mail::Reporter.\n\n$obj->AUTOLOAD()\nInherited, see \"Error handling\" in Mail::Reporter\n\n$obj->addReport($object)\nInherited, see \"Error handling\" in Mail::Reporter\n\n$obj->defaultTrace( [$level]|[$loglevel, $tracelevel]|[$level, $callback] )\nMail::Message::Field::Attribute->defaultTrace( [$level]|[$loglevel, $tracelevel]|[$level,\n$callback] )\nInherited, see \"Error handling\" in Mail::Reporter\n\n$obj->errors()\nInherited, see \"Error handling\" in Mail::Reporter\n\n$obj->log( [$level, [$strings]] )\nMail::Message::Field::Attribute->log( [$level, [$strings]] )\nInherited, see \"Error handling\" in Mail::Reporter\n\n$obj->logPriority($level)\nMail::Message::Field::Attribute->logPriority($level)\nInherited, see \"Error handling\" in Mail::Reporter\n\n$obj->logSettings()\nInherited, see \"Error handling\" in Mail::Reporter\n\n$obj->notImplemented()\nInherited, see \"Error handling\" in Mail::Reporter\n\n$obj->report( [$level] )\nInherited, see \"Error handling\" in Mail::Reporter\n\n$obj->reportAll( [$level] )\nInherited, see \"Error handling\" in Mail::Reporter\n\n$obj->trace( [$level] )\nInherited, see \"Error handling\" in Mail::Reporter\n\n$obj->warnings()\nInherited, see \"Error handling\" in Mail::Reporter\n"
                },
                {
                    "name": "Cleanup",
                    "content": "Extends \"Cleanup\" in Mail::Reporter.\n\n$obj->DESTROY()\nInherited, see \"Cleanup\" in Mail::Reporter\n"
                },
                {
                    "name": "The attribute",
                    "content": "$obj->addComponent(STRING)\nA component is a parameter as defined by RFC2045, optionally using encoding or continuations\nas defined by RFC2231. Components of an attribute are found when a field is being parsed.\nThe RFCs are very strict on valid characters, but we cannot be: you have to accept what is\ncoming in if you can.\n\nexample:\n\nmy $param = Mail::Message::Field::Attribute->new;\n$param->addComponent(\"filename*=iso10646'nl-BE'%Re\\47u\");\n\n$obj->charset()\nReturns the character set which is used for this parameter. If any component is added which\ncontains character set information, this is directly available. Be warned that a\ncharacter-set is case insensitive.\n\n$obj->language()\nReturns the language which is defined in the argument. If no language is defined \"undef\" is\nreturned, which should be interpreted as \"ANY\"\n\n$obj->name()\nReturns the name of this attribute.\n\n$obj->string()\nReturns the parameter as reference to an array of lines. When only one line is returned, it\nmay be short enough to fit on the same line with other components of the header field.\n\n$obj->value( [STRING] )\nReturns the value of this parameter, optionally after setting it first.\n"
                },
                {
                    "name": "Attribute encoding",
                    "content": "$obj->decode()\nTranslate all known continuations into a value. The produced value is returned and may be\nutf-8 encoded or a plain string.\n\n$obj->encode()\n"
                },
                {
                    "name": "Internals",
                    "content": "$obj->mergeComponent($attribute)\nMerge the components from the specified attribute into this attribute. This is needed when\ncomponents of the same attribute are created separately. Merging is required by the field\nparsing.\n"
                }
            ]
        },
        "DIAGNOSTICS": {
            "content": "Warning: Illegal character in parameter name '$name'\nThe specified parameter name contains characters which are not permitted by the RFCs. You\ncan better change the name into something which is accepted, or risk applications to corrupt\nor ignore the message.\n\nError: Package $package does not implement $method.\nFatal error: the specific package (or one of its superclasses) does not implement this\nmethod where it should. This message means that some other related classes do implement this\nmethod however the class at hand does not. Probably you should investigate this and probably\ninform the author of the package.\n\nError: Too late to merge: value already changed.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "This module is part of Mail-Message distribution version 3.012, built on February 11, 2022.\nWebsite: http://perl.overmeer.net/CPAN/\n",
            "subsections": []
        },
        "LICENSE": {
            "content": "Copyrights 2001-2022 by [Mark Overmeer <markov@cpan.org>]. For other contributors see ChangeLog.\n\nThis program is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself. See http://dev.perl.org/licenses/\n",
            "subsections": []
        }
    },
    "summary": "Mail::Message::Field::Attribute - one attribute of a full field",
    "flags": [],
    "examples": [],
    "see_also": []
}