http://qs1969.pair.com?node_id=527493


in reply to Changing the contents of a file

Since what you are substituting always occurs at the end of a line, the easiest way to do this seems to me to be something like:
perl -pi -e 's/turkey$/fox/' file_full_of_turkeys_that_you_want_to_be_ +foxes