Getopt::Long::Parser(3perl)

Getopt::Long::Parser3perl

Getopt::long object-oriented interface

Usage

    use Getopt::Long::Parser;
    my $p = Getopt::Long::Parser->new;
    $p->configure( %options );
    if ( $p->getoptions( @options ) ) { ... }
    if ( $p->getoptionsfromarray( \@array, @options ) ) { ... }

Configuration options can be passed to the constructor:

    my $p = Getopt::Long::Parser->new( config => [ %options ] );

Overview

"Getopt::Long::Parser" is an object-oriented interface to Getopt::Long. See its documentation for configuration and use.

Note that "Getopt::Long" and "Getopt::Long::Parser" are not object-oriented. "Getopt::Long::Parser" emulates an object-oriented interface, which should be okay for most purposes.

Constructor

    my $p = Getopt::Long::Parser->new( %options );

The constructor takes an optional hash with parameters.

config

An array reference with configuration settings. See "Configuring Getopt::Long" in Getopt::Long for all possible settings.

Methods

In the examples, $p is assumed to be the result of a call to the constructor.

configure

    $p->configure( %settings );

Update the current config settings. See "Configuring Getopt::Long" in Getopt::Long for all possible settings.

getoptionsfromarray

    my $res = $p->getoptionsfromarray( $aref, @opts );

getoptions

    my $res = $p->getoptions( @opts );

The same as "getoptionsfromarray( \@ARGV, @opts )".

Releases

2 releases since Debian 13 (Trixie); the text changed 1 time.

  1. 13
  2. Arch

Author

Johan Vromans <[email protected]>

From perl 5.44.0-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.