http://qs1969.pair.com?node_id=29432


in reply to When is a while not a while?

I'll take a flyer and suggest a couple of possibilities depending on the behaviour you want::

1. do {} while () -- this would allow the code to execute once before 'hanging' on the while. I can't really envision how this would apply to your situation, but hey, you never know.

2. Threads -- I've got admit that I've only used threading in Java, but there are at least three threading modules on CPAN.

What you'd want to do is have one thread waiting for keyboard input -- I'm not sure what the exact syntax would be, but you'd create the thread with a low priority/nice-ness so that other processes keep running (maybe even a sleep()), and spin off your other process as a seperate thread so that it can run without waiting for keyboard input (assuming that this is the behaviour you want).

The tricky part is establishing a safe way for the two threads to talk to each other -- in Java you have Thread-safe objects/methods that you can essentially use as a lock on your data ('don't read this until I've finished writing to memory/disk...').

I suspect that in Perl this will be a little tougher, but I'm sure that someone can either a) offer actual code, or b) point you to a module, to solve your problem.

Sorry I can't offer actual code, but this is outside the scope of my normal Perl coding...