So far I have this for "press any key" - I'm thinking there's a better way but this actually works with "ANY KEY" insted of the ENTER key and anything prior to it.
The Win32::Console is part of perl now I think so you don't have to do any install.
Hope it helps, I'm always hunting for a better 'any key'
use Win32::Console;
my $StdIn = new Win32::Console( STD_INPUT_HANDLE );
my $Password = "";
$StdIn->Mode( ENABLE_PROCESSED_INPUT );
print "Press Any Key\n";
while ( my $Data = $StdIn->InputChar( 1 ) ) {
print "$Data\n";
if ($Data ne "" {
last;
}
}
Another alternative is to download the Term module from CPAN and use a ReadMode/ReadKey combination.
Code:
#!usr/bin/perl -w
use strict;
use Term::ReadKey;
sub pause();
print "Test\n";
pause;
sub pause() {
print "Press any key to continue...";
ReadMode 'cbreak';
ReadKey(0);
ReadMode 'normal';
}
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.