david.shin has asked for the wisdom of the Perl Monks concerning the following question:


I want to factor out the GetOptions(...) call into a library but have run into a few issues.
So here's what I want to do:

Main Program:
- create a hash
- create an array of parameters I want to read off the command line in the GetOptions(...) format (ie "home=s", "instance=s", fileSuffix:s", etc)
- pass a reference to the hash and array to the Util method encapsulating the GetOptions call

Util method w/GetOptions call:
Now this is where the problem is, I don't know how to format a string so it can fill in the hash.
I tried iterating over each entry in the array and calling GetOptions(...) individually, but on the first call, it tries to load up all the paramters and then on subsequent calls cannot find any paramters (since they've been consumed by the first call) (if this is wrong, please correct me as well).

So then I found another method where you can pass in a hash ref and the parameter you want.
- ie GetOptions( \%myHash, "home=s");

So I tried to pass in one huge string consisting of all the parameters I want
( ie GetOptions( \%myHash, "home=s,instance=s,fileSuffx:s") but that didn't work either (which didn't surprise me).

Any suggestions out there? Thanks a lot!!