Hi Monks ^_^ This is my very first post. I honestly did not think I would need to, but after much searching, I am left with no choice because it's making me think about switching to C. (I know I said it... Lol!) Well first off I am trying to create a very large AI bot that will be embedded into my next computer's ArchLinux. It will have voice recognition, and say some random quotes through a generated voice at random times to simulate actual intelligence. I know I think I'm crazy too. I most definitely fail, but it will be a very good learning experience.
So here is my start off code taken from http://mind.sourceforge.net/perl.html
#!/usr/bin/perl -w
#
sub security;
sub sensorium;
sub emotion;
sub think;
sub volition;
sub motorium;
while (1)
{
security();
sensorium();
emotion();
think();
volition();
motorium();
}
sub security
{
# security
}
sub sensorium
{
# sensorium
print "Press ENTER or ESCAPE key: ";
$_ = <STDIN>;
exit if (/^\027/);
}
sub emotion
{
# emotion
}
sub think
{
# think
}
sub volition
{
# volition
}
sub motorium
{
# motorium
}
#---
The problem is that I cannot exit the loop at all unless I press <CONTROL>-C (^C). I thought that it might be trying to terminate just the sensory stub, and then looping back and executing it again. So I moved the "exit if" up into the actual while loop out of frustration, but to no avail. This is a screenie of the output:
http://is100.imagesocket.com/images/2012/02/02/2425592-4k99.png
I pressed enter twice, then I pressed the ESC key then enter, then finally ^C. That is the right hex for ESC correct? I was really hoping that I could find a way to close/exit the script with having to type into the terminal also. But nothing seems to be working right now. It should be such a simplistic script. I really cannot figure it out.
I even tried chomping, and chopping. Help would very much be appreciated. I don't want to end my project before I haven't even started. I am merely a beginner, Thanks for your time ^_^
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.