|Perl: the Markov chain saw|
Problem running code until a user hits a keyby davies (Vicar)
|on Dec 30, 2007 at 15:13 UTC||Need Help??|
davies has asked for the
wisdom of the Perl Monks concerning the following question:
I want to run code until the user hits a key (I donít care which key). In old fashioned BASIC itís simple:
Running this for about a second results in half a million iterations. But I canít work out how to do the same thing in Perl.
I have tried:
Another way, based on Perl cookbook recipe 15.6:
Both respond in the same way. They sit until a key is pressed, and then return 1. I've only waited for up to five seconds, but even if I get multiple iterations by waiting longer, it's not nearly fast enough. I think what is happening is that the code is being optimised too far, but I would welcome clarification on this. I donít actually need the counter in the finished code Ė Iím trying to initialise a series of pseudo-random number generators, but that code isnít relevant to this particular part of the problem. The counter is just there to satisfy me that something is happening.
TIA and regards,