use strict; use threads; use threads::shared; my @list = qw ( www.apple.com www.ibm.com www.oracle.com www.sun.com ); my @good: shared; my @bad: shared; my $thread; my @thread; foreach(@list){ push @thread, threads->new("ping", "$_"); } foreach $thread( @thread){ $thread->join; } print "Good: @good\n"; print "Bad: @bad\n"; sub ping { my $ip = shift; my @rv = `ping -n 1 -w 100 $ip`; foreach(@rv){ if (/(\d+\.\d+\.\d+\.\d+)/){ $ip = $1 }; push @good, $ip if /\(0% loss\)/g; push @bad, $ip if /\(100% loss\)/g; } }