Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Can't exit, except when I press ^C?

by roboticus (Chancellor)
on Feb 02, 2012 at 10:51 UTC ( #951408=note: print w/replies, xml ) Need Help??

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


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'.


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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://951408]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2018-05-25 17:17 GMT
Find Nodes?
    Voting Booth?