in reply to Terminating a parallel process opened with "system(..)"

I needed to something similar. AS the other post mentions Proc::Background did the trick. Here is the sample code. I wanted to listen on specific ports and then run an nmap scan from external host to see if the ports are reachable. This was part of a larger tool.
#!/bin/perl -w use strict; use warnings; use Proc::Background; use Net::OpenSSH; my @ports = ("443","8080"); my @threads = ''; my $index = 0; foreach my $port(@ports){ $threads[$index] = Proc::Background->new("/usr/bin/perl thread +.pl $port"); $index++; } my $ssh = Net::OpenSSH->new("remote.host.net", user=>"me",passwd=> +"******"); $ssh->error and die "Can't ssh to host\n"; my @output = $ssh->capture("nmap -p T:8080,443 my.host.name"); print @output; foreach my $thread (@threads){ print "Killing $thread\n"; $thread->die; } print "Done ";