in reply to simple timeout
#!/usr/bin/perl use strict; my $ndx = 0; my @servers = (1,2,3,4); my $globalServerNum; $SIG{'ALRM'} = \&time_out; print "\n\n"; foreach $ndx (@servers) { $globalServerNum = $ndx; eval { alarm(5); print "server $ndx please respond: "; my $answer = <STDIN>; my $timeleft = alarm(0); print "($timeleft) sec left\n"; } } print "\nbye bye end-of-workday\n"; exit; sub time_out { print "\nserver $globalServerNum timed out, go next\n"; next; #die "FED UP WAITING"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: simple timeout
by disciple01 (Novice) on Nov 08, 2004 at 16:54 UTC |