use strict; use warnings; my @hostnames = qw(www.leo.org dhbvg.xxx); foreach (@hostnames){ # my $a = `echo pinging $_ 1>&2 ; ping -c3 $_ 2>&1 | tee -a /dev/tty`; my $a = `ping -c3 $_ 2>&1`; if ($a =~ /unreach|unknown host/i){ print " For $_ : problems: $a."; } }