Try with Term::ReadKey, the man page says:
Term::ReadKey is a compiled perl module dedicated to providing simple control over terminal driver modes (cbreak, raw, cooked, etc.,) support for non-blocking
reads, if the architecture allows, and some generalized handy functions for working with terminals. One of the main goals is to have the functions as portable as
possible, so you can just plug in "use Term::ReadKey" on any architecture and have a good likelyhood of it working.
Here is a snippet of code that does what you need:
use Term::ReadKey;
ReadMode 4; # Turn off controls keys
while (not defined ($key = ReadKey(-1)) {
# No key yet
}
print "Get key $key\n";
ReadMode 0; # Reset tty mode before exiting
Hope this helps. Ciao, Valerio