1MIME::Field::ParamVal(3U)ser Contributed Perl DocumentatiMoInME::Field::ParamVal(3)
2
3
4

NAME

6       MIME::Field::ParamVal - subclass of Mail::Field, for structured MIME
7       fields
8

SYNOPSIS

10           # Create an object for a content-type field:
11           $field = new Mail::Field 'Content-type';
12
13           # Set some attributes:
14           $field->param('_'        => 'text/html');
15           $field->param('charset'  => 'us-ascii');
16           $field->param('boundary' => '---ABC---');
17
18           # Same:
19           $field->set('_'        => 'text/html',
20                       'charset'  => 'us-ascii',
21                       'boundary' => '---ABC---');
22
23           # Get an attribute, or undefined if not present:
24           print "no id!"  if defined($field->param('id'));
25
26           # Same, but use empty string for missing values:
27           print "no id!"  if ($field->paramstr('id') eq '');
28
29           # Output as string:
30           print $field->stringify, "\n";
31

DESCRIPTION

33       This is an abstract superclass of most MIME fields.  It handles fields
34       with a general syntax like this:
35
36           Content-Type: Message/Partial;
37               number=2; total=3;
38               id="oc=jpbe0M2Yt4s@thumper.bellcore.com"
39
40       Comments are supported between items, like this:
41
42           Content-Type: Message/Partial; (a comment)
43               number=2  (another comment) ; (yet another comment) total=3;
44               id="oc=jpbe0M2Yt4s@thumper.bellcore.com"
45

PUBLIC INTERFACE

47       set [\%PARAMHASH | KEY=>VAL,...,KEY=>VAL]
48           Instance method.  Set this field.  The paramhash should contain
49           parameter names in all lowercase, with the special "_" parameter
50           name signifying the "default" (unnamed) parameter for the field:
51
52              # Set up to be...
53              #
54              #     Content-type: Message/Partial; number=2; total=3; id="ocj=pbe0M2"
55              #
56              $conttype->set('_'       => 'Message/Partial',
57                             'number'  => 2,
58                             'total'   => 3,
59                             'id'      => "ocj=pbe0M2");
60
61           Note that a single argument is taken to be a reference to a
62           paramhash, while multiple args are taken to be the elements of the
63           paramhash themselves.
64
65           Supplying undef for a hashref, or an empty set of values,
66           effectively clears the object.
67
68           The self object is returned.
69
70       parse_params STRING
71           Class/instance utility method.  Extract parameter info from a
72           structured field, and return it as a hash reference.  For example,
73           here is a field with parameters:
74
75               Content-Type: Message/Partial;
76                   number=2; total=3;
77                   id="oc=jpbe0M2Yt4s@thumper.bellcore.com"
78
79           Here is how you'd extract them:
80
81               $params = $class->parse_params('content-type');
82               if ($$params{'_'} eq 'message/partial') {
83                   $number = $$params{'number'};
84                   $total  = $$params{'total'};
85                   $id     = $$params{'id'};
86               }
87
88           Like field names, parameter names are coerced to lowercase.  The
89           special '_' parameter means the default parameter for the field.
90
91           NOTE: This has been provided as a public method to support
92           backwards compatibility, but you probably shouldn't use it.
93
94       parse STRING
95           Class/instance method.  Parse the string into the instance.  Any
96           previous information is wiped.  The self object is returned.
97
98           May also be used as a constructor.
99
100       param PARAMNAME,[VALUE]
101           Instance method.  Return the given parameter, or undef if it isn't
102           there.  With argument, set the parameter to that VALUE.  The
103           PARAMNAME is case-insensitive.  A "_" refers to the "default"
104           parameter.
105
106       paramstr PARAMNAME,[VALUE]
107           Instance method.  Like param(): return the given parameter, or
108           empty if it isn't there.  With argument, set the parameter to that
109           VALUE.  The PARAMNAME is case-insensitive.  A "_" refers to the
110           "default" parameter.
111
112       stringify
113           Instance method.  Convert the field to a string, and return it.
114
115       tag Instance method, abstract.  Return the tag for this field.
116

SEE ALSO

118       Mail::Field
119
120
121
122perl v5.34.0                      2021-07-22          MIME::Field::ParamVal(3)
Impressum