in reply to Problem with String replace in file
Because | is a special character to regular expressions (which the left hand side of a substitution is). Read quotemeta (and probably perlretut and perlre as they also cover this).