wait_key.pl to HTML.

index -|- end

Generated: Mon Aug 29 19:35:07 2016 from wait_key.pl 2014/12/22 716. text copy

#!/usr/bin/perl -w
# NAME: wait_key.pl
# AIM: Just a test of wait_key...
use strict;
use warnings;
## use Term::TermKey; - NOT available

sub prt($) { print shift; }

sub get_stdin($) {
    my ($rc) = shift;
    ${$rc} = <STDIN>;
}

sub wait_key_input($) {
    my ($msg) = shift;
    if (length($msg)) {
        prt($msg);
    }
    my $char = '';
    get_stdin(\$char);
    if ($char =~ /^y/i) {
        return 1;
    }
    return 0;
}

prt("Wait key test... NOTE: An ENTER key is required to terminate the input!\n");

if (wait_key_input("Enter 'y' to continue : ")) {
    prt("Got 'y'... continuing...\n");
} else {
    prt("Did not get 'y' - Abort\n");
}

# eof - wait_key.pl

index -|- top

checked by tidy  Valid HTML 4.01 Transitional