Getopt...BoolMap(3pm)
π Getopt::Yath::Option::BoolMap β bestie's guide to multi-boolean options β¨
okay so picture this: you don't want one sad little yes/no flag, you want a whole lil family of them, all matched by one regex, all landing in one hashref. That is literally this class, and it lives in the user-contributed Perl docs, in the Getopt::Yath namespace, file name Getopt...BoolMap (the ellipsis is the man page being dramatic, not me π). Option::BoolMap β options that take multiple boolean values, periodt.
π NAME
Getopt::Yath::Option::BoolMap β options that take multiple boolean values. that's the name, that's the whole vibe, no notes. π
πΈ DESCRIPTION
okay so here's the tea π: this thing matches several --OPTION-XXX and --no-OPTION-XXX options based on a given regex. Then it populates a hashref β and every option it found gets a true or false value, depending on whether it had the --no- prefix.
so --no- prefix = false, no prefix = true. it's giving very simple, very iconic, very slay. β¨
π¦ SYNOPSIS
option features => (
type => 'BoolMap',
clear => sub { {features => 0} },
pattern => qr/feature-(.+)/,
description => 'Match '--feature-(foo), --no-feature-(foo), etc and set {foo => $BOOL} in the 'features' option',
);
look at her. she's gorgeous. she's matching a whole pattern family and setting a hash for you. ππ
π§ METHODS
All methods from Getopt::Yath::Option::Map are inherited β you get that whole inheritance situation, it's giving free real estate. The following ones are overridden or otherwise noteworthy, iykyk:
requires_argβ depends on the value of therequires_argattribute. Defaults tofalse.custom_matchesβ returns a coderef that matches command-line arguments against thepatternregex. When--MATCHis used the key gets atruevalue; when--no-MATCHis used it gets afalsevalue. π₯no_arg_valueβ returns the option's field name with a value of1.
π ADDITIONAL ATTRIBUTES
pattern => qr/.../β Required (like, actually required, not optional, don't skip her π). A regex pattern (with a capture group) that is embedded intoqr/^--(no-)?$pattern$/. The first capture group from the pattern is used as the hash key.requires_arg => BOOLβ iftrue, the option requires an argument. Defaults tofalse.custom_matches => sub { ... }β optional coderef to override the default matching logic. It receives the option object, the input string, and the parse state.
π SOURCE
The source code repository for Getopt-Yath can be found at http://github.com/Test-More/Getopt-Yath/. go look, she's right there bestie π«Ά
β MAINTAINERS
Chad Granum exodist@cpan.org
πΈ AUTHORS
Chad Granum exodist@cpan.org
π COPYRIGHT
Copyright 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/
okay and for the cute sign-off: this whole page is perl v5.40.1, dated 2026-05-10, filed under Getopt...BoolMap(3pm) in the User Contributed Perl Documentation. that's the footer, that's the lore, and that's the post. stay matching, bestie πβ¨π¦
π¦ where this page comes from
- ubuntu stonking: libgetopt-yath-perl 2.000011-2 Β· 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