http://www.perlmonks.org?node_id=316644

hotshot has asked for the wisdom of the Perl Monks concerning the following question:

Hi guys!

I have a function that prints to console the line Please press any key to continue and waits for a keyboard key to be presses, it was working for ages. I'v just noticed that it doesn't work anymore, it gets stuck in the middle and no matter what key I press, the program doesn't continue on the console. Here it is:
use Term::ReadKey; sub pressAnyKey { print "Press any key to continue...\n\n"; ReadMode 4; # turn off control keys While (not defined ($key = ReadKey(-1))) {} readMode 0; # restore read mode }
If I remember right this function was suggested by another monk, a long time ago when I needed an advice on the matter, and it worked perfectly since than. It seems that the function get stuck on the while loop, as if no key press breaks out of it.
Anyone see something?

Title edit by tye/small>