foreach (@connections_pending) { my $fh; my $remote = accept( $fh, $_ ); my ( $port, $iaddr ) = sockaddr_in($remote); my $peeraddress = inet_ntoa($iaddr); my $t = threads->create( \&connection, $fh ); } #### sub upload_file { my ( $fh, $req_ ) = @_; my %req = %$req_; my $header_ = $req{HEADER}; my %header = %$header_; my ($file, $desc, $dirpath ) = (undef, undef, undef); my $boundary = trim (form_data_boundary( $header{'content-type'} )); my $user_agent = $header{'user-agent'}; # Now i will process the post buffer and copy the file #to local machine into a temp directory. I shall also #receive the filename, destination directory and some #other metadata information. ($file, $desc, $dirpath) = process_POST_buffer($fh, $req_, $boundary); # Then i spawn another thread to do the pre-processing on this file my $t = threads->create( \&pre_process, $file, $desc, $dirpath ); } #### sub pre_process { threads->detach(); my ( $file_name, $desc, $dirpath ) = @_; my ( $file1, $file2, $file3 ) = ( getTempFile(), getTempFile(), getTempFile() ); my $metadata = i_PreProcessor->new( FILENAME => $file_name, SEARCHXMLFILE => $file1, DESCRIPTION => $desc, MAPXMLFILE => $file2, TAGXMLFILE => $file3, DIRNAME => $dirpath ); $metadata->build2(); #delete temp files. my @files = ( $file1, $file2, $file3 ); unlink(@files); threads->exit(); }