http://qs1969.pair.com?node_id=1197614


in reply to Trickery with Getopt::Long (flag option, with optional integer arg)

Use the :i specifier. Refer to Summary of Option Specifications.
use warnings; use strict; use Getopt::Long; my $arg = -1; GetOptions('arg:i' => \$arg) or die; print "$arg\n";

Replies are listed 'Best First'.
Re^2: Trickery with Getopt::Long (flag option, with optional integer arg)
by stevieb (Canon) on Aug 18, 2017 at 15:14 UTC

    That's great and works exactly as I need, thanks toolic!

    I completely overlooked that in the docs. I was kind of thinking there had to be a way.