I am calling a java code from perl that queries the DB ,sets the retrieved data to a webservice api and sends the webservice call. But the webservice call stops after some time (with the exception read timed out) based on the value configured in CGITimeout attribute in IIS (I am linking perl in IIS). Increasing the CGITimeout is not a valid solution for me.

Is there any way to make the perl script to run until all the data from the DB is being processed? (Using system/fork/wait)

Hmmm... The question in the text of your posting somehow does not math the title of the post.

Of course you can continue executing your Perl program, while a background task is running. There are several ways how to do it. You can for example use fork/exec (respectively system(1,...)) to launch the process in background. See the perlipc and perlport pages for more information.

Timing out a process is a different matter. For this, you can use the alarm function.