Getopt...Parser(3perl)
π Getopt::Long::Parser β the vibe-coded OO glow-up of Getopt::Long π
(that's Getopt...Parser(3perl), from the Perl Programmers Reference Guide, bestie β we're in the Perl 5 manual pages section π)
okay so. you love Getopt::Long. iconic. but sometimes you want it to look like an object, and that's literally all this module is here for. no cap.
β¨ NAME β¨
Getopt::Long::Parser β the object-oriented interface to Getopt::Long π«Ά
πΈ SYNOPSIS πΈ
use Getopt::Long::Parser;
my $p = Getopt::Long::Parser->new;
$p->configure( %options );
if ( $p->getoptions( @options ) ) { ... }
if ( $p->getoptionsfromarray( \@array, @options ) ) { ... }
and the little party trick: you can hand your configuration options straight to the constructor bestie β¨
my $p = Getopt::Long::Parser->new( config => [ %options ] );
π¦ DESCRIPTION π¦
Getopt::Long::Parser is an object-oriented interface to Getopt::Long. For all the configuration and usage deets, go read its docs, k? π
now. important. real talk. π
Getopt::Long and Getopt::Long::Parser are not object-oriented. Getopt::Long::Parser emulates an object-oriented interface β it's giving OO, it's cosplaying OO β and that should be okay for most purposes π
π CONSTRUCTOR π
my $p = Getopt::Long::Parser->new( %options );
it takes an optional hash with parameters. optional!! so chill of it.
configβ an array reference stuffed with configuration settings. For every possible setting, see "Configuring Getopt::Long" in Getopt::Long π
π METHODS π
in all these examples, $p is assumed to be whatever came out of calling the constructor. we love a consistent main character π
β¨ configure β¨
$p->configure( %settings );
updates the current config settings, live, on the fly π§ For every possible setting, see "Configuring Getopt::Long" in Getopt::Long.
β¨ getoptionsfromarray β¨
my $res = $p->getoptionsfromarray( $aref, @opts );
β¨ getoptions β¨
my $res = $p->getoptions( @opts );
literally the same as writing getoptionsfromarray( \@ARGV, @opts ) π like, that's it. that's the whole method. it's getoptionsfromarray but pointed at @ARGV by default. periodt.
π₯ SEE ALSO π₯
Getopt::Long
π AUTHOR π
Johan Vromans <jvromans@squirrel.nl> β the original of the originals fr fr π
πΈ COPYRIGHT AND DISCLAIMER πΈ
This program is Copyright 1990,2015,2023 by Johan Vromans. This program is free software; you can redistribute it and/or modify it under the same terms as Perl.
also this page came from perl v5.44.0 and it's dated 2026-10-17 β so yeah, that's where this whole thing lives. have fun parsing your args, bestie, you're gonna slay π
β¨ππ¦
π¦ where this page comes from
- arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND 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