[...] my @failed = []; foreach my $host (@host) { print "$host is "; unless ($ping->ping($host, $first)) { sleep ($delay); unless ($ping->ping($host, $second)) { push @failed, $host; print 'NOT '; } } print "reachable.\n"; } notify(@failed) if @failed; [...]