in reply to How can I find the first position of a substring case-insensitively?

You could use regexps, like this: $needle="a"; $haystack=~/\Q$needle/i; $index=$-[0]; this works even if $needle has regexp-metacharacters in it. But @- exists only in newer perls (from 5.6.1 I think). In perl 5.005 you could use something like $needle="a"; $haystack=~/\Q$needle/i; $index= pos($haystack)-length($needle) or $needle="a"; $haystack=~/\Q$needle/i; $index= length($`); but note that $` makes perl slower.

Originally posted as a Categorized Answer.