use strict; use warnings; use Net::Telnet; use IO::Socket; use IO::Select; use Data::Dumper; my @hosts = ('localhost')x2; my %results; $t1->open( Host => $hosts[0] ); $t2->open( Host => $hosts[1] ); my $s = IO::Select->new( $t1, $t2 ); $t1->send('start first comand'); $t2->send('start second command'); while ( $t1 && $t2 ) { while ( my @ready = $s->can_read() ) { foreach my $fh (@ready) { if ( $t1 && $t1 == $fh ) { my $line = $t1->getline; push @{ $results{t1} }, $line; $s->remove($t1); $t1->close; undef $t1; } elsif ( $t2 && $t2 == $fh ) { my $line = $t2->getline; push @{ $results{t2} }, $line; $s->remove($t2); $t2->close; undef $t2; } } } } print Dumper( \%results )
In reply to Re^3: Working in parallel
by james2vegas
in thread Working in parallel
by mpapec
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |