in reply to Function speeds: lc() vs. eq vs. =~

use Benchmark.

I did a benchmark and came up with the following:

Benchmark: timing 1000000 iterations of eq, lc, re... eq: 3 wallclock secs ( 2.76 usr + 0.00 sys = 2.76 CPU) lc: 3 wallclock secs ( 2.69 usr + 0.00 sys = 2.69 CPU) re: 3 wallclock secs ( 3.13 usr + 0.00 sys = 3.13 CPU)
lc is your first code snippet, eq the second, and re the third.

You *really* don't need to worry about the differences in speed, unless you're doing this 100000 times or something like that.

Seriously: don't try to optimize things like this. Testing case-insensitive equality is *such* a fast operation that you shouldn't be worrying about it--yes, even in an interactive situation.

Instead worry about Getting It Right. For example, what does your second code snippet do if $type is 'Cr' or 'cR'? Maybe you don't think you need to worry about those things, but I say you should: it's definitely more important than worrying about a couple of milliseconds per every 100000 case-insensitive equality checks.