while(<DATA>){ print if s/tom/Mary/i; # Substitute tom with Mary } __DATA__ tom Mary Jack James Jon Kate