How to scrub VT100/ANSI control chars in Net::Telnet
<p>I am using <code>Net::Telnet</code> to connect to a HP ProCurve Switch to login and backup the config. However I ran into issues where <code>waitfor</code> returns VT100/ANSI control chars:</p>

<pre><code>&lt; 0x00000: ff fd 18 ff  fd 1f ff fb  01 1b 5b 32  4a 1b 5b 3f  ..........[2J.[?
&lt; 0x00010: 37 6c 1b 5b  33 3b 32 33  72 1b 5b 3f  36 6c 1b 5b  7l.[3;23r.[?6l.[
&lt; 0x00020: 31 3b 31 48  1b 5b 3f 32  35 6c 1b 5b  31 3b 31 48  1;1H.[?25l.[1;1H
&lt; 0x00030: 48 50 20 4a  39 37 32 38  41 20 32 39  32 30 2d 34  HP J9728A 2920-4
&lt; 0x00040: 38 47 20 53  77 69 74 63  68 0d 0d 0a  53 6f 66 74  8G Switch...Soft
&lt; 0x00050: 77 61 72 65  20 72 65 76  69 73 69 6f  6e 20 57 42  ware revision WB
&lt; 0x00060: 2e 31 35 2e  31 32 2e 30  30 31 35 0d  0d 0a 0d 0d  .15.12.0015.....
&lt; 0x00070: 0a 43 6f 70  79 72 69 67  68 74 20 28  43 29 20 31  .Copyright (C) 1
&lt; 0x00080: 39 39 31 2d  32 30 31 34  20 48 65 77  6c 65 74 74  991-2014 Hewlett
&lt; 0x00090: 2d 50 61 63  6b 61 72 64  20 44 65 76  65 6c 6f 70  -Packard Develop
&lt; 0x000a0: 6d 65 6e 74  20 43 6f 6d  70 61 6e 79  2c 20 4c 2e  ment Company, L.
&lt; 0x000b0: 50 2e 0d 0a  0d 0a 20 20  20 20 20 20  20 20 20 20  P.....
</code></pre>

<p>Unfortunately, this screws up <code>waitfor</code> because if I try to <code>waitfor(/^password:/i)</code> it will return a string with those control chars in it, or wait forever since the regex is never matched. </p>

<p>Is there any way to have <code>Net::Telnet</code> automatically remove those control characters? Is there any way to have <code>waitfor</code> only care about ASCII printable characters?</p>