sub process3 { my ($start,$end,$node) = @_; my %workers; my ($cur, $line, $pos); my $done = 0; my ($rnode, $obj); my @file; tie @file, 'Tie::File', "inputfile" or die "couldnt tie"; $workers{$node} = open_handle($node, "glob"); #this opens the ssh connection. my $to_node = $workers{$node}[WRITE]; my $from_node = $workers{$node}[READ]; $workers{$node}[SENT] = $start; $line = $file[$workers{$node}[SENT]]; print $to_node "$cur\n"; $workers{$node}[SENT]++; while(1){ my $res; $res = $from_node->getline(); chomp($res); ($obj, $rnode) = split(',',$res); print "$obj\n" if $res; last if ($workers{$node}[SENT] > $end); $line = $file[$workers{$node}[SENT]]; print $to_node "$line\n" unless($workers{$node}[SENT] > $end ); $workers{$node}[SENT]++; } } #i know i can put this in a loop, but i decided to leave it for clarity. my $thr1 = threads->new(\&process3, 0,$endline, "c001n05"); my $thr2 = threads->new(\&process3, 0,$endline, "c001n06" ); my $thr3 = threads->new(\&process3, 0,$endline, "c001n07" ); my $thr4 = threads->new(\&process3, 0,$endline, "c001n08" ); my $thr5 = threads->new(\&process3, 0,$endline, "c001n09" ); my $thr6 = threads->new(\&process3, 0,$endline, "c001n10" ); my $thr7 = threads->new(\&process3, 0,$endline, "c001n11" ); my $thr8 = threads->new(\&process3, 0,$endline, "c001n12" ); my $thr9 = threads->new(\&process3, 0,$endline, "c001n13" ); my $thr10 = threads->new(\&process3, 0,$endline, "c001n14" ); my $thr11 = threads->new(\&process3, 0,$endline, "c001n15" ); my $thr12 = threads->new(\&process3, 0,$endline, "c001n16" ); $thr1->join(); $thr2->join(); $thr3->join(); $thr4->join(); $thr5->join(); $thr6->join(); $thr7->join(); $thr8->join(); $thr9->join(); $thr10->join(); $thr11->join(); $thr12->join();