#!/usr/bin/perl @hosts=("8.8.8.8","8.8.4.4"); foreach(@hosts){ $command .= "ping -c 3 $_; "; } my @lines = qx/$command/; foreach(@lines){ if(/PING/){ foreach $host(@hosts){ if(/PING ($host).*/){ $host_key = $host; } } }elsif(/rtt min\/avg\/max\/mdev = (.*)\/(.*)\/(.*)\/(.*) .*/){ print "$host_key min:$1 avg:$2 max:$3 mdev:$4\n"; } }