in reply to
How to substitute all the words before a certain word in the middle of a line?
I'm assuming that there should have been line breaks in the sample data, so that each sentince was on a separate line. Also, this code will match everything before the first occurance of the trigger word (nice in this case). You can replace <DATA> with another filehandle or with <> depending upon where you want to get the lines.
my $triggerword = "nice";
my $replacement = "A ";
This is a nice weather.
He is a nice guy.
We have some nice food in our dinner.