in reply to Search and replace logic

Try something like this (you may have to diddle the modifiers to s/// a touch):
my @data = <DATA>; my @swap = qw/nce nse/; my %replace = ( @swap, reverse @swap ); my $search_for = join('|', keys %replace); s/($search_for)/$replace{lc $1}/gi foreach @data; __DATA__ incense license luminance
update: added a /g to the s///