if(/nce|nse/) { s/$&/replace with what it's not/i; print; } #### if(nse) { s/nse/nce/i; print; } if(nce) { s/nce/nse/i; print; }