I got my solution.
This is a true work of art dear monks: Thanks to BrowserUK!!
use strict;
use strict;
use threads;
use Thread::Queue;
use Time::HiRes qw(usleep);
$| =1 ;
sub pipeCommand {
my $Q = new Thread::Queue;
async{
my $mypipe;
my $pid = open($mypipe, '-|', "traceroute 66.186.184.205");
$Q->enqueue( $_ ) while <$mypipe>;
$Q->enqueue( undef );
}->detach;
return $Q;
}
my $pipe = pipeCommand() or die;
while(1) {
if( $pipe->pending ) {
my $line = $pipe->dequeue or last;
chomp( $line );
print $line,$/;
}
else {
# Ogla's thread
# my $msg = $network_thread->dequeue_nb();
# if($msg eq "EXIT"){
# $pipe->enqueue( undef );
# return undef;
# }
usleep(100_000);
}
}
------------------------------
"Geneva will not marry you no matter how much you love Larry Wall." Geneva Wall
|