#!/usr/bin/perl
while (<>) {
    1 while s/[^\b][\b]\e\[K//;  # remove all non-backspace followed by backspace and escape [K (backup?)
    1 while s/[^\b][\b]//;  # remove all non-backspace followed by backspace
    1 while s/\e\[[0-9;]*P//; # various up-arrow commands?
    print;
}
