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
- fedora 44: perl-MIME-tools 5.517-1.fc44 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms