use Win32API::File 0.08 qw( :Func ); use Net::Ping; if( $#ARGV > 1 || ! $ARGV[0] ) { usage(); exit 1; } $source = '\path\to\local\file(s)'; $destination = '\path\to\remote\host'; $hostname = $ARGV[0]; $p = Net::Ping->new("icmp"); if( $p->ping($hostname )) { print "\u$hostname is alive.\n"; copy($source, $destination); } else { print "\u$hostname is not reachable\n"; $p->close(); } sub usage { print "Please enter either an IP address or a Hostname\n"; print "Usage: Copied file/s to specified Hostname or IP address"; }