in reply to Not Using So Many 'if' Statements
my @host = qw[ 192.168.15.2 192.168.16.2 192.168.17.2 192.168.18.2 ]; my $stout; my $counter = 0; while ($stout = run($host[$counter])) { last unless $stout == 256; if ($counter < $@host) { print "$host[$counter] not responding, trying $host[$counter+1]\n" +; $counter++; } else { print "$host[$counter] not responding, no more hosts to try.\n"; last; } }
just a side note, "$stout == '256'" forces perl to take the string 256 and make it into a number - the quotes are useless there.
-- zigdon
|
|---|