in reply to Can't exit, except when I press ^C?

TalsiOrah:

The ESC character is chr(27), but you're looking for chr(23). The reason? /^\027/ is looking for octal 27 which is decimal 23. You should use /^\033/ which will give you what you're looking for.

Update: I (briefly) looked around, but didn't find a link to perl documentation on escaping numbers in strings. In an expression, prefix of '0' on a number tells perl to use octal, and a prefix of '0x' tells it to use hexadecimal. In a string, it's similar, you use a prefix of '\0' for octal, and '\x' for hexadecimal.

Update 2: Perlbotics provided a link perlnumber to what I was looking for, and corrected me on the prefix used for hexadecimal in strings. I clarified the previous update accordingly. The way I worded it previously would have had people using '\0x4C' expecting an 'M', but they'd get chr(0) followed by 'x4C'.

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Replies are listed 'Best First'.
Re^2: Can't exit, except when I press ^C?
by TalsiOrah (Initiate) on Feb 02, 2012 at 15:18 UTC
    Thanks!! That worked!! Am I doing the looping correctly? Like I said, I'm extremely newbie haha. Is there a way to make a global like variable to exit the script? Like read input from outside the terminal? Oh I'm on Linux by the way.