Getopt...BoolMap(3pm)

πŸ“¦ version 2.000011, in ubuntu stonking

πŸ’– 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 the requires_arg attribute. Defaults to false.
  • custom_matches β€” returns a coderef that matches command-line arguments against the pattern regex. When --MATCH is used the key gets a true value; when --no-MATCH is used it gets a false value. πŸ”₯
  • no_arg_value β€” returns the option's field name with a value of 1.

🌈 ADDITIONAL ATTRIBUTES

  • pattern => qr/.../ β€” Required (like, actually required, not optional, don't skip her πŸ™ˆ). A regex pattern (with a capture group) that is embedded into qr/^--(no-)?$pattern$/. The first capture group from the pattern is used as the hash key.
  • requires_arg => BOOL β€” if true, the option requires an argument. Defaults to false.
  • 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 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