[vienna.pm] Nodelay input?
Toni Andjelkovic
toni at soth.at
Fri Oct 5 19:17:38 CDT 2001
* * * vienna-pm-list * * *
Michael Bauer wrote on Sat, Oct 06 2001 (01:34:01 +0200):
> dazu bringen möglichst ohne use Curses oder andere module einen nodelay input
> zu akzeptieren. Sprich wenn nix kommt gehts weiter im text.
z. b. so:
#!/usr/bin/perl -w
use strict;
my $var = "not initialized";
print STDERR "please enter foo (5 seconds timeout): ";
my $rin = "";
vec($rin,fileno(STDIN),1) = 1;
my $rc = select($rin, undef, undef, 5); # warte 5 sekunden auf STDIN
if ($rc > 0) {
sysread(STDIN, $var, 1024);
} else {
warn "timeout";
warn "error: $!" if $!;
}
# weiter im code ...
print "var: $var\n";
siehe perldoc -f select, IO::Select,
IO::Handle, IO::Pty, IO::Stty.
cu,
--
Toni Andjelkovic
<toni at soth.at>
###
You are subscribed to vienna-pm-list as Toni Andjelkovic <toni at soth.at>
http://www.fff.at/fff/vienna.pm/
More information about the Vienna-pm
mailing list