for (){ chomp; $case = $_ & ' ' x length; s/old/NEW/i; print $_ | $case. "\n"; } __DATA__ old_word OLD_WORD oLd_wOrd olD_worD