Asynchronous perl execution

A

andrewjones86

Hi,

I have a Perl CGI script which when ran needs to search through a lot
of text files and remove strings. What I would like to do is have this
sub routine running as a child on its own, while the parent goes and
loads the webpage. I don't want the parent to have to wait for the
child to finish, or its not really asynchronous.

I have looked into fork(), but its not easy to understand and when I
tried more than a basic example I ran into problems.

Any pointers in the right direction would be very much appreciated.

Thanks,
Andrew
 
J

Jürgen Exner

I have a Perl CGI script which when ran needs to search through a lot
of text files and remove strings. What I would like to do is have this
sub routine running as a child on its own, while the parent goes and
loads the webpage. I don't want the parent to have to wait for the
child to finish, or its not really asynchronous.

I have looked into fork(),

Yes, that is the best approach. Another possibility would be to use system()
or qx() to start a new process and mark the call in such a way that the
OS/system shell will start the process in the background.
but its not easy to understand and when I
tried more than a basic example I ran into problems.
Any pointers in the right direction would be very much appreciated.


Might have helped if you explained what those problems were and showed some
actual sample code that created those problems.

jue
 
X

xhoster

Hi,

I have a Perl CGI script which when ran needs to search through a lot
of text files and remove strings. What I would like to do is have this
sub routine running as a child on its own, while the parent goes and
loads the webpage. I don't want the parent to have to wait for the
child to finish, or its not really asynchronous.

I have looked into fork(), but its not easy to understand and when I
tried more than a basic example I ran into problems.

What problems? It is hard to solve problems without knowing what they are.
Any pointers in the right direction would be very much appreciated.

Your child process should probably close or re-open STDIN, STDOUT, and
STDERR. And you should follow the posting guidelines.

Xho
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top