use Getopt::Long; $p = Getopt::Long::Parser->new; $p->configure(...configuration options...); # Do some computing here to come up with list of option descriptions if ($p->getoptions(...options descriptions...)) ... if ($p->getoptionsfromarray( \@array, ...options descriptions...)) ...