Doozer has asked for the wisdom of the Perl Monks concerning the following question:
I am after some advice on the best way to search an array for multiple values sequentially.
My scenario is this:
I have an array with anywhere up to 10 elements. The elements are Wifi Security types such as WPA, WPA2, WEP 64, WEP 128, etc.
What I would like to do is go through the array and select the best available security type according to what is available in the array. The array will differ as I work through different routers, so one router may only support up to WEP 128 while another will have WPA2 available. In my mind, I can see it working in that it will first search the array for WPA2, if it doesnt find it, it will then look for WPA, if thats not found, it will move on to WEP 128, and so on.
I am struggling to think of the best way to handle this. I have a vague idea but I think it will end up being a loooong bit of code with many many if statements and foreach loops.
Any advice would be greatly appreciated and I will happily provide more info if what I have said is not very clear.
Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Search an array for values sequentially
by choroba (Cardinal) on May 20, 2014 at 09:20 UTC | |
|
Re: Search an array for values sequentially
by AppleFritter (Vicar) on May 20, 2014 at 09:26 UTC | |
|
Re: Search an array for values sequentially
by AnomalousMonk (Archbishop) on May 20, 2014 at 12:57 UTC | |
|
Re: Search an array for values sequentially
by Discipulus (Canon) on May 20, 2014 at 09:28 UTC | |
by AnomalousMonk (Archbishop) on May 20, 2014 at 12:43 UTC | |
|
Re: Search an array for values sequentially
by RichardK (Parson) on May 20, 2014 at 09:30 UTC | |
by Doozer (Scribe) on May 20, 2014 at 09:37 UTC |