$char =~ tr/ -~// and $input .= $char
The '-' indicates a range, from ' ' to '~', which if you look at a basic ASCII chart, is all the plain printable (visible and take up one character position) characters.
$char =~ tr/\b\x7f// is used because on my system the key labeled "Backspace" returns "\b" when running in xterm and "\x7f" when running on the Linux console.
BTW, for your comment in the chatterbox, the \b in tr/\b\x7f// is an actual character "\x08" whereas the \b in a regex is a metacharacter and not an actual character.
The code implementing the backspace is wizardry :)
The idea is simple -> if you currently have N choices, find the longest initial substring that gives you more than N choices.
The wizardry is the the design of regex itself, credit Larry and the implementors...
The concept that regex finds the longest match is crucial in this program both for backspace and for advancing to the next decision point.
In reply to Re^6: [challenge] Nested autocompletion -- winner program unveiled to me
by tybalt89
in thread [challenge] Nested autocompletion
by Discipulus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |