sub getfile(){ my $file = $_[0]; my $pid; if (!defined($pid = fork())) { die "cannot fork: $!"; } elsif ($pid) { while (1){ my $command = ; chomp($command); if($command =~ m/^\s*abort\s*/){ $ftp->abort(); last; } } } else { $ftp->get($file); } }