#!/usr/bin/perl -w use strict; my @hosts = <>; # list of hosts to ping my $depth = 5; # number of children my $size = 800; # packet size my @pid; # store child pids here open (OUT, ">>results"); for (0..$depth - 1) { $pid[$_] = fork; if ($pid[$_]) { print "$_\n"; # for debugging } else { foreach my $host (splice(@hosts, $_ * (scalar @hosts)/$depth, ($_ + 1) * (scalar @hosts)/$depth)) { chomp $host; my @result = `ping -c 1 -s $size $host`; $result[1] =~ s/^.*=//mg; # strip the data down to $result[1] =~ s/ ms.*$//mg; # decimal miliseconds print OUT "$host\t$result[1]"; } } } close OUT;