Getopt...::State(3pm)
π NAME π
okay bestie, so this is Getopt::Yath::State (the Getopt...::State(3pm) page, hi πΈ) β and it's literally the receipt you get handed back after parsing command-line options. It's the representation of the result of parsing command-line options, no cap. π§Ύβ¨
π DESCRIPTION π
So like, this object is what gets returned by parse_options in Getopt::Yath (and also by process_args in Getopt::Yath::Instance, iykyk). It's holding all of this for you:
- the parsed settings π
- any skipped or remaining arguments
- the stop token (if any)
- environment variable changes
- cleared options
- and the modules whose options were used
And here's the tea: this object is a blessed hash, so plain old hash-key access like $state->{settings} still works for backwards compatibility. Iconic of it. However, accessor methods are preferred β that's the main character move. π
β¨ SYNOPSIS β¨
my $state = parse_options(\@ARGV, stops => ['--']);
my $settings = $state->settings; # Getopt::Yath::Settings object
my $remains = $state->remains; # args after a stop token
my $skipped = $state->skipped; # skipped non-options
my $stop = $state->stop; # what token stopped parsing
my $env = $state->env; # env vars that were/would be set
my $cleared = $state->cleared; # options cleared via --no-opt
my $modules = $state->modules; # modules whose options were used
π¦ METHODS π¦
$settings = $state->settingsβ hands you theGetopt::Yath::Settingsobject with all the parsed option values, organized by group. slay.$arrayref = $state->skippedβ gives you back an arrayref of the args that got skipped while parsing (this happens whenskip_non_optsorskip_invalid_optsis enabled, bestie).$arrayref = $state->remainsβ an arrayref of args that were never processed, usually the ones sitting after a stop token like"--". they're just vibing back there π«Ά$string = $state->stop$state->set_stop($token)βstopreturns the token that made parsing stop (think"--","::"), orundefif parsing finished normally, no drama.set_stopis used internally during parsing β that's a backstage thing, not a you thing π$hashref = $state->envβ a hashref of environment variable changes. keys are the variable names, values are what was set (or what would have been set, if you're usingno_set_env). and a value ofundefmeans the variable was cleared β poof, gone π$hashref = $state->clearedβ a hashref tracking which options were explicitly cleared via"--no-opt". the structure is exactly{ group_name => { field_name => 1 } }, keep the receipt π§Ύ$hashref = $state->modulesβ a hashref of the modules whose options got used during parsing. keys are module names, values are usage counts. the popularity contest π
π₯ SOURCE π₯
The source code repository for Getopt-Yath lives at <http://github.com/Test-More/Getopt-Yath/> π
π 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/>
and that's the whole page bestie, ur welcome πβ¨ this wasperl v5.40.1, dated2026-05-10, from theGetopt...::State(3pm)page β go forth and parse, periodt π
π¦ 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