Pinging a host, system(), ping()

 
#!/usr/bin/perl -w

foreach my $node qw( hasa1 hasb1 hasc1 hasNotExist)
{
    my $ret = !system( "ping -c 1 -w 1 -q $node 1>/dev/null 2>&1");
    if( $ret)
    {
	print "$node is online \n";    
    }
    else
    {
	print "$node is offline \n";    
    }    
}