in reply to Regarding speed: Is elsif or just if faster?

Lately, a lot of my code has had to do a lot of conditional juggling, based on the values passed to it. This is a piece of example code:
[snip] And it's fast enough for me, but it has me wondering: is it faster to use elsif for this, or to just chain the statement into a whole pile of if statements?

It is faster to write in C. Well, not really: it will probably take longer to write your program in C, but it will execute faster. So, sorry for repeating what others already wrote in this thread, but they say that repetita iuvant: if you have good reasons to be concerned by this, then by all means you should switch to C, or some other language. Otherwise you shouldn't be concerned at all and repeat the premature optimization mantra quite a number of times.

However, to remain slightly more in topic: in Perl one seldom needs long chains of if's and elsif's; even "simple" else's are often not needed as there are alternative syntactical choices with the same semantics that make for much more readable, and maintainable, code.

BTW: two relevant quotes not as widely known as Hoare's one:

Bottlenecks occur in surprising places, so don't try to second guess and put in a speed hack until you have proven that's where the bottleneck is.
- Rob Pike

The First Rule of Program Optimization: Don't do it.
The Second Rule of Program Optimization (for experts only!): Don't do it yet.

- Michael A. Jackson