#! /usr/bin/perl # # Wrapper around ping use strict; use warnings; use NetAddr::IP; use feature ":5.10"; my $host = $ARGV[0]; my $ip = new NetAddr::IP $host; die "Unknown host: $host\n" unless defined($ip); given ($ip->version()) { when (4) { exec { '/bin/ping' } 'ping', @ARGV or die "Can't exec ping"; } when (6) { exec { '/bin/ping6' } 'ping6', @ARGV or die "Can't exec ping6"; } default { die "Unknown address: $host\n"; } }