I have a file with multiple backspace characters (^H
) in it. I'd like to be able to "apply" those backspaces within perl. I found a few solutions, but none of them worked in my case.
The critical line is this one:
test>>M^H ^HManagement.^H^H^H^H^H^H^H^H^H^Hanagement.F^H ^HFiles.^H^H^H^H^Hiles.s^H ^Hs.^H ^Hc^H ^H^H ^Hscript.^H ^H^H^H^H^Hripts^H ^H^H ^H^H ^H^H ^H^H ^H^H ^H^H ^Hscripts.^H.s^H ^Hshow_file ^H^H^H^H^H^H^H^H^Hhow_file = transform_factory_to_running^M
The result should look like this:
test>>Management.Files.scripts.show_file = transform_factory_to_running^M
Within vi i am able to transform the text correctly as suggested in https://stackoverflow.com/a/1298728/2837411.
But the perl solution, which is also suggested in this question: https://stackoverflow.com/a/1298970/2837411 didnt worked for me (using $_
):
s{([^\x08]+)(\x08+)}{substr$1,0,-length$2}eg;
The output for this is:
test>>Management.Files.sscriptriptscripts.show_file = transform_factory_to_running^M
All the backspaces are vanished but it looks like as if a few of them are applied to a another backspace?!