in reply to Pick random element from array and delete it
#!/usr/bin/perl -l use strict; use warnings; my $connectionStatus = "down"; my @listOfServers = qw(abc def lmn stu xyz); foreach my $server ( @listOfServers ) { if ($connectionStatus eq 1) { print "Connection status is: 'up'"; last; } elsif ($connectionStatus ne 1) { $server = $listOfServers[rand @listOfServers]; print "Connection status is: 'down'"; next unless $connectionStatus eq 1; } else { print "This is not going to work ..."; } }
|
|---|