MIME::F...ParamVal(3)

πŸ’– MIME::Field::ParamVal β€” the structured-MIME-field bestie πŸ’–

okay so this is MIME::Field::ParamVal(3), from the User Contributed Perl Documentation section, and it's a whole subclass of Mail::Field for structured MIME fields. she's giving parser-girlie, she's giving abstract superclass, she's iconic. let's GO πŸ¦‹


✨ NAME ✨

MIME::Field::ParamVal β€” subclass of Mail::Field, for structured MIME fields. periodt. πŸ’…


🌸 SYNOPSIS 🌸

like, here's the whole vibe in code, no cap:

# Create an object for a content-type field:
$field = new Mail::Field 'Content-type';

# Set some attributes:
$field->param('_'        => 'text/html');
$field->param('charset'  => 'us-ascii');
$field->param('boundary' => '---ABC---');

# Same:
$field->set('_'        => 'text/html',
            'charset'  => 'us-ascii',
            'boundary' => '---ABC---');

# Get an attribute, or undefined if not present:
print "no id!"  if defined($field->param('id'));

# Same, but use empty string for missing values:
print "no id!"  if ($field->paramstr('id') eq '');

# Output as string:
print $field->stringify, "\n";

πŸŽ€ DESCRIPTION πŸŽ€

bestie. listen. this class is the abstract superclass of, like, most MIME fields. it handles any field whose general syntax looks like this:

Content-Type: Message/Partial;
    number=2; total=3;
    id="oc=jpbe0M2Yt4s@thumper.bellcore.com"

and the way that comments are supported between items?? obsessed. look:

Content-Type: Message/Partial; (a comment)
    number=2  (another comment) ; (yet another comment) total=3;
    id="oc=jpbe0M2Yt4s@thumper.bellcore.com"

comments just vibing in between the parameters. we love to see it πŸ’–


πŸ‘‘ PUBLIC INTERFACE πŸ‘‘

πŸ’œ set [\%PARAMHASH | KEY=>VAL,...,KEY=>VAL]

Instance method, babes. set this field. the paramhash should contain parameter names in all lowercase, with the special "_" parameter name signifying the "default" (unnamed) parameter for the field:

# Set up to be...
#
#     Content-type: Message/Partial; number=2; total=3; id="ocj=pbe0M2"
#
$conttype->set('_'       => 'Message/Partial',
               'number'  => 2,
               'total'   => 3,
               'id'      => "ocj=pbe0M2");

now the little detail that gets people every time: a single argument is taken to be a reference to a paramhash, while multiple args are taken to be the elements of the paramhash themselves. iykyk.

supplying undef for a hashref, or an empty set of values, effectively clears the object. gone. deleted. no thoughts head empty 🫢

the self object is returned. she comes back. always.

🧚 parse_params STRING

Class/instance utility method. extract parameter info from a structured field, and return it as a hash reference. for example, here's a field with parameters:

Content-Type: Message/Partial;
    number=2; total=3;
    id="oc=jpbe0M2Yt4s@thumper.bellcore.com"

and here's how you'd extract them:

$params = $class->parse_params('content-type');
if ($$params{'_'} eq 'message/partial') {
    $number = $$params{'number'};
    $total  = $$params{'total'};
    $id     = $$params{'id'};
}

like field names, parameter names are coerced to lowercase. and the special '_' parameter means the default parameter for the field.

⚠️ NOTE: this has been provided as a public method to support backwards compatibility, but you probably shouldn't use it. fr fr. she said don't.

🌈 parse STRING

Class/instance method. parse the string into the instance. any previous information is wiped β€” like, fully gone, no recovery, rip to that data 😭. the self object is returned.

may also be used as a constructor. multitasking queen πŸ‘‘

⭐ param PARAMNAME,[VALUE]

Instance method. return the given parameter, or undef if it isn't there. with argument, set the parameter to that VALUE. the PARAMNAME is case-insensitive. a "_" refers to the "default" parameter.

πŸ“ paramstr PARAMNAME,[VALUE]

Instance method. like param(): return the given parameter, or empty if it isn't there. with argument, set the parameter to that VALUE. the PARAMNAME is case-insensitive. a "_" refers to the "default" parameter.

πŸ’… stringify

Instance method. convert the field to a string, and return it. glow-up complete ✨

πŸ¦‹ tag

Instance method, abstract. return the tag for this field.


πŸ”₯ SEE ALSO πŸ”₯

  • Mail::Field

perl v5.42.0 Β· 2026-02-11 β€” and that's the whole page bestie, written by the User Contributed Perl Documentation girlies, delivered to you with love πŸŽ€ mwah πŸ’‹ no cap, go parse something slay πŸ’–βœ¨

πŸ“¦ where this page comes from