tie @$output, 'IPC::Shareable', $glue, { %options } || die "Tie failed\n"; my $pm=new Parallel::ForkManager(50); foreach $keyword ( @keywords ) { $pm->start and next; $key= join('\+', split(/\ /, $keyword)); $remote = IO::Socket::INET->new( Proto => "tcp", PeerAddr => $host, PeerPort => $port, ); unless ($remote) { die "cannot connect to http daemon on $host on $port" } $remote->autoflush(1); print $remote "GET $prefix$key HTTP/1.0" . $BLANK; $count="0"; while ( <$remote> ) { if (/flist/i) { $count++; } } push (@$output, "$keyword,$count"); close $remote; $pm->finish(); } $pm->wait_all_children; # Write message to tmp file. $tempfile = basename($file); $tmpfile = "/tmp/$tempfile"; open(TMPFILE, ">$tmpfile") || die "Can't open $tmpfile for writing"; foreach $line ( @$output ) { $count++; print "$count\n"; print "$line\n"; print TMPFILE "$line\n"; } } close(TMPFILE);