In my Perl script, I have a routine that is called hundreds of times with many different sets of parameters, since the only values โโthat are sent are those that are different from the defaults. (It goes without saying that the number of permutations and combinations is very large). To make it more reliable, I would like to do some parameter checking. Here is an abridged version of my routine (the actual version has dozens of parameters with very specific, sometimes long names):
# Obtain any parameters that differ from the defaults and send for processing sub importantSub { my %params = ( commandType => 5, commandId => 38, channel1Enable => 0, channel2Enable => 0, channel3Enable => 0, channel4Enable => 0, channel5Enable => 0, channel6Enable => 0, channel7Enable => 0, channel8Enable => 0, channel9Enable => 0, channel10Enable => 0,
As you can see, I am currently checking to see if the number of values โโmatches, as if something was sent as "chan1Enable" instead of "channel1Enable", it will throw that number away.
But since there are so many subroutine calls from several other scripts written by several other engineers, I would like to find a way to find the WHICH value was incorrect (for example, not just saying that there was an unexpected parameter, say that "chan1Enable" is invalid). Also, if multiple values โโwere incorrect, I would like to list them all.
What is the most efficient way to do this?
(I ask about efficiency, as the function is currently being called in more than 400 different ways and is likely to continue to grow as the application expands.)