csotzing has asked for the wisdom of the Perl Monks concerning the following question:
# Name: showLoop # Desc: MainLoop for displaying text menu and handling input # In: loopMax - max number of looping # Out: None sub showLoop { my ($self,$loopMax) = (@_); my $loopNum = 0; while (1) { # clear screen clearScreen(); # display menu print "\n $self->{'title'}\n\n"; foreach my $item (@{$self->{"itemsRef"}}) { my $label = $item->getLabel(); print " $label\n"; } print "\n Select an option or quit [q]: "; # handle user response my $resp = $self->getResponse(); if ($resp =~ /^[qQ]$/) { last; } else { $self->handleResponse($resp); } $loopNum++; if ((defined $loopMax) && ($loopNum >= $loopMax)) { last; } # flush stdout and stdin autoflush STDOUT,1; # how to flush/empty stdin without blocking? # continue print "\n Return continues\n"; <STDIN>; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Ignore STDIN during processing
by flounder99 (Friar) on Jun 18, 2002 at 15:02 UTC | |
|
Re: Ignore STDIN during processing
by ariels (Curate) on Jun 18, 2002 at 13:20 UTC | |
by csotzing (Sexton) on Jun 18, 2002 at 13:50 UTC |