use Net::Ping; $host = shift; $p = Net::Ping->new(); $p{"timeout"} = 0.05; # or whatever print "$host is alive.\n" if $p->ping($host); $p->close();