Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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

by roboticus (Canon)
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?

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.


Comment on Re: Can't exit, except when I press ^C?
Select or Download Code
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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://951408]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2014-08-21 02:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (127 votes), past polls