Hey Monks
I have two arrays. One contains command line switches the other contains command line switches followed by values. I want to isolate the values after each switch and assign them to that switch. I also want to assign the values following
the next switch and so on for an infinite number of switches.
@switches = ("-d", "-l", "-m");
@values = ("-d", "disk1", "disk2", "disk3", "-l", "load1", "load2", "l
+oad3", "load4", "-m" "memory1", "memory2");
So when my program asks what are the values for
"l" (switch names decided at run time so it could be anything not just
"l", "d"or
"m") it should recieve an array containing
("load1", "load2", "load3", "load4").
I know it has something to do with hashes (probably) but my experience with them is limited.
What would be the best way to implement this?
Thanks in advance
j
o
h
n
i
r
l
.
Sum day soon I'Il lern how 2 spelI (nad tYpe)
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.