9 Einträge, 1 Seite |
my $in = <STDIN>;
1
2
3
4
5
6
7
8
9
eval {
$|++;
local $SIG{ALRM} = sub { die "timeout!" };
alarm(2);
print "INPUT: ";
my $input = <STDIN>;
print "INPUT: $input";
};
print "END!\n";
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use IO::Select;
$|++;
my $s = IO::Select->new;
$s->add( \*STDIN );
print "INPUT: ";
if ( $s->can_read(2) ) {
my $input = <STDIN>;
print "INPUT: $input";
}
else {
print "TIMEOUT!\n";
}
print "END\n";
1
2
3
4
5
6
7
8
9
10
11
$|++;
vec( my $in, fileno(STDIN), 1 ) = 1;
print "INPUT: ";
if ( select( $in, undef, undef, 2 ) ) {
my $input = <STDIN>;
print "INPUT: $input";
}
else {
print "TIMEOUT!\n";
}
print "END\n";
9 Einträge, 1 Seite |