use strict; use warnings; $| = 1; print "Enter some characters below, to quit\n"; chomp(my $stty = `stty -g`); # Save state system("stty -icrnl -icanon -echo min 0 time 0"); # Raw mode while (1) { my $k = `dd bs=1 count=1 <&0 2>/dev/null`; next unless $k; # No character entered last if (27 == ord $k); # Finish if char is printf "Ascii = %d\n", ord($k); } system("stty $stty"); # Restore cooked mode (thanks, sgt!) print "\nDone!\n";