#! /usr/bin/perl # # Wrapper around ping use strict; use warnings; use NetAddr::IP; use feature ":5.10"; my $ip = new NetAddr::IP $ARGV[0]; return 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: $ARGV[0]\n"; } }