MouseX...pt::GLD(3pm)
π NAME π
MouseX::Getopt::GLD β bestie, it's literally a Mouse role that processes your command line options using Getopt::Long::Descriptive π
That's the whole vibe. You slap this role on your class and suddenly your object knows how to read @ARGV like it's nothing. No cap. β¨
πΈ SYNOPSIS πΈ
Okay so here's the whole lil story arc, in three acts π
Act 1: the class. You write a regular old Mouse class, but you with the role. And you mark the attributes you want to come from the command line:
## In your class
package My::App;
use Mouse;
with 'MouseX::Getopt::GLD';
has 'out' => (is => 'rw', isa => 'Str', required => 1);
has 'in' => (is => 'rw', isa => 'Str', required => 1);
# ... rest of the class here
Notice how out and in are both required => 1? Yeah. The command line is gonna be the one supplying them. That's the whole point π«Ά
Act 2: the script. You don't call new. You call new_with_options, and it does the β¨thingβ¨:
## in your script
#!/usr/bin/perl
use My::App;
my $app = My::App->new_with_options();
# ... rest of the script here
Act 3: the command line. You actually run it and pass the flags, and the object gets built from them:
## on the command line
% perl my_app_script.pl -in file.input -out file.dump
And that's it. That's the demo. It's giving effortless, honestly ππ₯
Heads up bestie: this page is short on purpose β the role does the work, and the details of how the option parsing goes down live with Getopt::Long::Descriptive and its friends. This is just the entrance π
π¦ SIGN-OFF π¦
And that's the page, bestie π This one came out of the User Contributed Perl Documentation pile, running on perl v5.32.1, dated 2021-09-16. Go forth and parse some options, you absolute icon ππΈ
π¦ where this page comes from
- debian bookworm: libmousex-getopt-perl 0.38-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libmousex-getopt-perl 0.38-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libmousex-getopt-perl 0.38-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