in reply to Strip escape sequences

What do you want to do with the string? If you print it to the terminal, the escape codes will have the effect they would have had anyway (colour, etc). This might be OK.

If you want to process the output and find failure or success, the escape codes won't hurt that. You can still match the string against /FAIL/ or /OK/.

And if you want to keep all wordchars and whitespace you could do something like:

$str =~ s/[^\w\s]//;
but it depends on what you are trying to achieve.