in reply to What is the most efficient perl switch/case statement?

That's a bit hard to benchmark, as it will depend on what is being switched, how many cases there are, and what the frequency of the cases is.

For instance, if there are a hundred cases, and each case is taken about 1 out of 100 times, a hash based solution might be best. If all the cases are small non-negative integers, then an array based solution is to be preferred. But if one case is taken far more than any other, an if/elsif chain, with the common case first might be the most efficient solution.

Abigail

  • Comment on Re: What is the most efficient perl switch/case statement?