egzoti4en has asked for the wisdom of the Perl Monks concerning the following question:
Hello guys,
I really really need your help fast.
I'm doing a project and I have no idea how to do something.
Here is the deal.
I have a while cycle where i read every key pressed. When i press 'Enter' i want to execute a sub which has a while cycle in it but also there is a sleep in it.
Here is some example code :
do { if($key eq "\n") #execute sub_example() if($key eq "261) #do something else }while ((key = getch()) ne ERR) sub_example { do {#....... sleep 5 #.... while(1>0)} }
So my issue is that when i execute sub_example the program freezes and waits for the cycle in the sub to finish. I want it to run in the background and still have the possibility to read from the keyboard and do stuff.
Thank you very much for your help i really needed.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Execute a sub in the background
by choroba (Cardinal) on Feb 01, 2012 at 13:17 UTC | |
by egzoti4en (Initiate) on Feb 01, 2012 at 13:28 UTC | |
by BrowserUk (Patriarch) on Feb 01, 2012 at 14:02 UTC | |
by egzoti4en (Initiate) on Feb 01, 2012 at 14:37 UTC | |
by BrowserUk (Patriarch) on Feb 01, 2012 at 14:58 UTC | |
by chessgui (Scribe) on Feb 01, 2012 at 14:46 UTC | |
|
Re: Execute a sub in the background
by Anonymous Monk on Feb 01, 2012 at 14:58 UTC | |
by egzoti4en (Initiate) on Feb 01, 2012 at 15:14 UTC | |
by chessgui (Scribe) on Feb 01, 2012 at 15:36 UTC | |
by egzoti4en (Initiate) on Feb 01, 2012 at 15:40 UTC | |
by chessgui (Scribe) on Feb 01, 2012 at 15:47 UTC | |
|