Test2:...Prefix(3pm)
π Test2::Harness::Settings::Prefix β the Test2:...Prefix(3pm) page, bestie edition π
okay so welcome to the manual page for Test2::Harness::Settings::Prefix, which lives in the Test2:...Prefix(3pm) corner of the man page universe (Perl's User Contributed Perl Documentation section, iykyk). buckle up, this one's short and sweet but lowkey powerful β¨
πΈ NAME πΈ
Test2::Harness::Settings::Prefix β the abstraction of a settings category, aka a prefix. that's the whole name. iconic. short. no notes. π
π DESCRIPTION π
so basically, this class represents a settings category β which everybody just calls a prefix. that's it. that's the description. she's a category. she holds settings. main character energy fr π
β¨ SYNOPSIS β¨
here's the vibe, copy-paste ready:
# You will rarely if ever need to construct settings yourself, usually a
# component of Test2::Harness will expose them to you.
my $settings = $thing->settings;
my $display = $settings->display;
# Once you have your prefix you can read data from it:
my $verbose = $display->verbose;
# If you dislike autoload methods you can use the 'field' method:
my $verbose = $display->field('verbose');
# You can also change values:
$display->field(verbose => 1);
# You can also use the autoloaded method as an lvalue, but this breaks on
# perls older than 5.16, so it is not used internally, and you should only
# use it if you know you will never need an older perl:
$display->verbose = 1;
okay so a few things: you're rarely if ever gonna build settings yourself β usually some component of Test2::Harness just hands them to you like a lil gift π. then you read stuff out of your prefix, or set stuff into it. and if autoload methods give you the ick, there's always field. choose your fighter. π«Ά
π¦ METHODS π¦
heads up bestie: any field that does not conflict with the predefined methods can be accessed via AUTOLOAD, which generates the methods as needed. so many methods, all of them conjured on demand, it's giving magic. β¨
$scalar_ref = $prefix->vivify_field($field_name)β this will force a field into existance. (yes, "existance," exactly like the original, no we will not be correcting her, she's valid π ) it returns a scalar reference to the field, and you can use that ref to set the value:
my $vref = $display->vivify_field('verbose'); # Create or find field
${$vref} = 1; # set verbosity to 1
$bool = $prefix->check_field($field_name)β checks if a field is defined or not. returns a bool. simple. clean. slay. π$val = $prefix->field($field_name)<br>$val = $prefix->$field_name<br>$prefix->field($field_name, $val)<br>$prefix->$field_name = $valβ get or set the value of the specified field. this will throw an exception if the field does not exist. so do not go asking for fields that aren't real, she will yell at you π
Note: the lvalue form $prefix->$field_name = $val breaks on perls older then 5.16. (yes, "then," again, verbatim, being faithful to the source is the whole assignment π)
$thing = $prefix->build($class, @args)β this creates an instance of$class, passing along the key/value pairs from the prefix as arguments. you can also toss in extra arguments via@args. it's giving "here's my whole personality, plus a lil extra." π₯$hashref = $prefix->TO_JSON()β this method is what lets settings get serialized into JSON. the all-caps name is not a drill, she means business. π
π SOURCE π
the source code repository for Test2-Harness lives right here:
http://github.com/Test-More/Test2-Harness/
go. peek. it's yours. π¦
π MAINTAINERS π
- Chad Granum
<exodist@cpan.org>
π AUTHORS π
- Chad Granum
<exodist@cpan.org>
πΈ COPYRIGHT πΈ
Copyright 2020 Chad Granum <exodist7@gmail.com>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://dev.perl.org/licenses/
and that's the whole page, bestie!! π huge thanks to perl v5.40.1 for hosting this lil masterpiece, timestamped 2026-05-10 β you ate, Test2:...Prefix(3pm), no cap. periodt. πβ¨
π¦ where this page comes from
- ubuntu stonking: libtest2-harness-perl 1.000172-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms