has said, there's no way to do it other than by rewriting the entire file after where you're modifying. However, there are things that can severely reduce the actual amount of stuff you have to code to accomplish that.
For your specific example, the -lpe -i.bak oneliner is probably the easiest. Here's an example of something using Tie::File
, which allows you to treat a file as an array of lines (change the array, change the file).
tie @array, 'Tie::File', '/data/syslog/log.backup' or die "Damnit, Jim
+, he's dead: $!";
s/$ip/$txt/ for @array;
}"for split/</;$_=$,,y[A-Z a-z]