firstav.pl (531B)
1 # firstav.pl - sample "first available" dispatching algorithm, 2 # implemented as an external Perl program 3 4 #!/usr/bin/perl 5 6 use strict; 7 8 print STDERR ("firstav.pl: Invocation: @ARGV\n"); 9 my $n = shift (@ARGV); 10 for my $i (0..$n - 1) { 11 my $addr = shift (@ARGV); 12 my $av = shift (@ARGV); 13 my $conn = shift (@ARGV); 14 print STDERR ("firstav.pl: $i: backend at $addr, $av, $conn connections\n"); 15 if ($av eq 'available') { 16 print ("$i\n"); 17 exit (0); 18 } 19 } 20 print STDERR ("firstav.pl: Nothing available!\n"); 21 exit (1);