Hi,
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!!
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.