in reply to Range in Getopt
You can evaluate options with Getopt::Long using a custom subroutine, like this:
GetOptions catches the die and throws it as a warning and returns false. When using the custom subroutine, you need to handle assigning to the variable for your option yourself.
use Getopt::Long; my $_debug; GetOptions('d=i' => sub { $_debug = $_[1]; ($_debug > 0 && $_debug <= 4) or die "Invalid Debug Level ($_d +ebug)" } ) and warn $_debug;
GetOptions catches the die and throws it as a warning and returns false. When using the custom subroutine, you need to handle assigning to the variable for your option yourself.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Range in Getopt
by roho (Bishop) on Oct 03, 2012 at 13:26 UTC | |
by james2vegas (Chaplain) on Oct 03, 2012 at 18:34 UTC |
In Section
Seekers of Perl Wisdom