in reply to Re^2: A better way of lookup?
in thread A better way of lookup?

RichardK,

Actually, both outer 'if / else' conditional statements could be reduced to just 'return ...' since each previous test did a 'return...' if the test was 'true'.

Interestingly, use of the 'elsif' gave the most performance improvement! Someone on PerlMonks many years ago showed how it was better, all I did was remember and continue to use it in my scripts.

Not as much of an improvement as the 'elsif', but since BrowserUk may have more information about the frequency of the inputs, I left it in with the hope that it would help. Another consideration is that BrowserUk uses 64bit Windows and I use mostly 32bit *nix. That's why the benchmarking is critical, since the results may be different in his environment. Please note, that I had to add brackets around the 'return' in order to compile his original script in my environment. YMMV!

Regards...Ed

"Well done is better than well said." - Benjamin Franklin