in reply to Changing the contents of a file

Here's my shot at it, assuming "turkey" isn't always going to be the same pattern/word.
while(<DATA>) { s#(elephant\s+\*\s+)(.*?)\w+$#$1$2fox# if (!/-ugly/); print; } __DATA__ elephant * -ugly /leave/this/alone elephant * /only/change/->/turkey elephant * turkey elephant * -ugly /leave/this/alone elephant * /only/change/->/turkey elephant * -ugly /leave/this/alone elephant * turkey

This is somewhat of a kludge, as I wanted to use a negative look-behind on the "-ugly", but I couldn't get it to work.

If "turkey" is always going to be "turkey", then the solution is a lot easier: s/turkey$/fox/