foreach $host (@host_array) { if( $p->ping($host, 2) ) { print "$host is alive.\n"; } else { print "$host is dead\n"; } }