|Perl: the Markov chain saw|
Trying to understand exactly what you mean by "more arguments".
Are you saying that you currently have arguments -i, -p, and -o, and your customer wants to add arguments -x, -y, and -z?
Or, are you saying you currently handle two arguments for each parameter, and your customer wants to use 5 for each parameter?
If you're talking about the former, I'd imagine you'd have to make some mods in your program to do that anyway. Before the processOne subroutine only is taking three paramters. Now, you'd have to not only pass in five parameters, but modify the code to actually use them. If you are referring to the same three parameters, but more values for them. You could do something like this:
That will process all values of all the options against each other. So, if you have two options for each, the processOne subroutine will execute eight times. If there are 3 of each parameter, the processOne subroutine will execute 27 times.
If you add a parameter -x, you'd have to modify your processOne subroutine anyway. Adding another foreach loop in that structure would probably be relatively simple compared to the other coding changes you'd have to make. Is it efficient? Well, the number of times a loop has to process quickly grows with each additional value. That's not exactly efficient, but that's what you said you wanted.
In reply to Re: Storing multiple arguments in a data structure that allows for future expansion
by Anonymous Monk