PetaMem has asked for the wisdom of the Perl Monks concerning the following question:
I'd like to use the Getopt::Long module at two places: 1) in a generic module providing various general purpose tasks and 2) in a script doing some specific task. This script is of course using the module mentioned under 1). So we have:
The script (I called it mgo.pl for Multiple GetOpt):
The module (MGO.pm):#!/usr/bin/perl -w use MGO; use Getopt::Long; GetOptions('help' => \ (my $help), 'version' => \ (my $version), ); print "HELP : $help\n" if(defined $help); print "VERS.: $version\n" if(defined $version);
package MGO; use Getopt::Long; GetOptions('cpu=i' => \ (my $cpu), 'quiet' => \ (my $quiet), ); print "CPU : $cpu\n" if(defined $cpu); print "QUIET: $quiet\n" if(defined $quiet); 1;
Now no matter what I do, I get for every option, that is not defined in MGO.pm an "unknown option: <option>". How do I tell GetOpt::Long to ignore unknown options (the docs are silent about this)? Or how do I split the Options processing in the above meantioned way?
Thanks for any hints.
Bye
PetaMem All Perl: MT, NLP, NLU
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Multiple GetOptions?
by jeffa (Bishop) on Feb 15, 2004 at 17:25 UTC | |
by PetaMem (Priest) on Feb 15, 2004 at 17:33 UTC | |
|
Re: Multiple GetOptions?
by Abigail-II (Bishop) on Feb 15, 2004 at 17:17 UTC | |
|
Re: Multiple GetOptions?
by PetaMem (Priest) on Feb 15, 2004 at 17:14 UTC | |
by sheep (Chaplain) on Feb 15, 2004 at 17:27 UTC |