my $output = `who`; my ($ip) = $output =~ /^.*?(\d+\.\d+\.\d+\.\d+)$/gis; my $ping = `ping -a $ip`; print $ping;