in reply to need help: substitute n-th word in a line

my $count = 0; my $N = 7; # Example. my $new_word = "new word"; s/(\w+)/++ $count == $N ? $new_word : $1/ge;

Untested though.

Abigail