Ahmed Moustafa wrote: > Tagore Smith wrote: > > > Ahmed Moustafa wrote: > > > > > >>So, how can a new different process by forked? Or, how a function be > >>called and the next step execute without waiting for the previous > >>function to terminate? > >> > > > > For your original question (threads) see perldoc perlthrtut. > > > > When you fork a child process the call to fork returns the child pid to > > the parent and 0 to the child. So you can write code that tests the return > > value and does one thing in the parent process (continue forking children to > > deal with the rest of your files) and another in the child process (process > > the current file). You can also use exec to execute another process which is > > not a "clone" of the parent. > > > > See perldoc -f fork and perldoc -f exec. > > > > Out of curiosity, why do you want to do this? > > > The main loop looks for files which are sent via FTP. Once a file is on > the server, it should be encrypted. The encryption process is slow so > some files stay as plain text waiting for their turns to be found and > encrypted.
That's plausible :). I was worried you might be thinking about doing this to large pre-existing directory trees. If the parent process is solely devoted to looking for and encrypting these files you may find that using separate processes to do this doesn't help much, and may in fact hurt- but I don't know everything about your situation, so then again it may be warranted. I'd stay away from threads unless you have a lot of time to devote to this, but using fork should be pretty straightforward (assuming your platform is Unix-like - process creation is more expensive under Windows). Tagore Smith -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]