in reply to swaping words

open (HANDLE, "$file"); open (HANDLE, ">>$file");

I'd think you only need to open the filehandle once.
The second open() statement is opening $file for appending only, which can't be useful in this case.

Why not use s/$word_1/$word_2/i or similar?