in reply to Case-sensitive substitution with case-insensitive matches
s/(bad)/my $str = "sad"; if (substr($1, 0, 1) eq 'B') { ucfirst $str }; $str/gie;
but that strikes me as ugly. Another approach would be building a hash with the possibilities:
Build the hash programmatically if necessary.my %insens = ( bad => 'sad', Bad => 'Sad', bAd => 'sAd', ); s/(bad)/$insens{$1}/gi;
|
|---|