I would like to substitute globally in a File with s///g and then print the changed lines and line numbers to a log. How can such thing be done? I would use a while (s///) but in some cases that can lead to infinite loops because substitute starts always from the beginning (eg. s/T/TT/).