#!/usr/bin/perl use strict; use warnings; use Net::Ping; my $down; my $host = $ARGV[0]; my $host2 = $ARGV[1]; my $rc = ( PING($host) == 0 ) ? "$host is up" : ( PING($host2) == 0 ) ? "$host2 is up" : "Neither $host or $host2 are reachable"; print "$rc\n"; sub PING { my $host = shift; my $p = Net::Ping->new("icmp"); return ( $p->ping($host) ) ? 0 : 1; }