use strict; use warnings; my $fileName = "test.txt"; open (JE, "+< $fileName") || die "Can not open the file "; my $ou = join "", ; $ou=~s/findtext/changetext/gs; seek JE, 0, 0; print JE $ou; close (JE);