open my $pipe, "traceroute ... |" or die; my $start = time; my $buf = ''; while(1) { my $vin = ''; vec($vin, fileno($pipe), 1) = 1; if (select($vin, undef, undef, 1)) { sysread $pipe, $buf, 2048, length $buf or last; } last if time - $start > $timeout; } close $pipe; # traceroute output is in $buf now