sub remove_ansi {
for (@_) {
$_ =~ s/\033\[[\?|0-9|\;]+?[a-z]//gi;
}
}
Use like 'chop' and 'chomp', for example:
remove_ansi $string; # Remove ANSI from $string
remove_ansi $a, $b; # Remove ANSI from $a and $b
Note:
$string = remove_ansi $string; # Does NOT do what you expect!