#!/perl/bin/perl -w use threads qw(yield); use strict; use Benchmark; my @childs; my $child; my (@rv, @RV); my @list; my $list; @list = qw ( www.perl.org www.ibm.com www.coke.com www.oracle.com www.hp.com ); #Dies if you iterate more than once :( timethese (1 , { 'threaded' => sub { foreach $list (@list){ push @childs, threads->create( "ping" , "$list" ); } foreach $child (@childs){ $child->join(); } undef @childs; }, 'non-threaded' => sub { foreach (@list){ ping($_); } } }); sub ping { my $ip = shift; @rv = `ping -n 1 -w 500 $ip`; foreach(@rv){ return "$ip up\n" if /\(0% loss\)/g; return "$ip down\n" if /\(100% loss\)/g; } }