Getopt...::State(3pm)

πŸ“¦ version 2.000011, in ubuntu stonking

πŸ’… 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 the Getopt::Yath::Settings object 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 when skip_non_opts or skip_invalid_opts is 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) β€” stop returns the token that made parsing stop (think "--", "::"), or undef if parsing finished normally, no drama. set_stop is 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 using no_set_env). and a value of undef means 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 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 was perl v5.40.1, dated 2026-05-10, from the Getopt...::State(3pm) page β€” go forth and parse, periodt πŸ’…
πŸ“¦ where this page comes from