in reply to Translating Bash to Perl

There's nothing new here. It checks for \x1B, "[" and "A" in a row, and you already knew that.