in reply to Multitasking in Perl
As has already been stated, fork is the most likely solution (until perl6 when the threading support will likely finally be intrinsic to the language).
However, please be aware that fork creates subprocesses. These subprocesses are independant of your parent process. Thus, merely setting a value of "$done = 1" in your subprocess will not affect the parent process in any way, shape, or form. Same in the reverse - the parent setting a variable won't affect the child (after the fork occurs). If this is acceptable (the subprocesses don't interact with each other nor with the parent process - e.g., they transform files on disk), then great. If not, then you'll need to also investigate methods of inter-process communication (IPC).
Update: BrowserUk notes using threads. Threads have similar issues to the above issues with fork from what I understand. The method of inter-thread communication in perl is not quite as simple as it is in some other languages, such as Java. All methods available to fork are available, plus sharing variables directly. However, upon reading the threads and threads::shared documentation, I discarded it as too cumbersome (and volatile), although I desperately miss thread usage when programming in perl (compared to other languages).
|
|---|