gsarin 0 Newbie Poster

Hi,

I have a perl cgi script as follows:

$|=0;
close(STDERR); 
open(STDERR, "> E:\\output.err"); 


# instantiate a new CGI object
my $cgi = new CGI;

my @params = $cgi->param();
my $length = @params; 
my $calc= $cgi->param($params[0]);

print "something on the browser"
print "tell the user that so and so routine is running"

#calls a procedure proc and passes the above input variables.


sub proc{

# calls batch files using system command.
$res = system ("some path to a batch file");

}

close(STDERR);
unlink("E:\\output.err");

exit(0);

The script runs fine. But the only problem is that when I try to run it more than once in parallel, the second instance waits for the first one to finish and so on.

In other words the perl script freezes and stops accepting commands until the first process finishes. So the browser displays nothing (no initial print statements) until the previous instance finishes execution.

I want the subroutine to execute sequentially, but also want the browser to NOT freeze and print the initial statements (line 13 & line 14) for every execution.

How do I accomplish this ? Do I need to use threads ?

Any pointers will be appreciated.

Thanks in advance..