in reply to Create a separate process with a sub...
Take a look at threads. If you are using AS, then the threads module is locate under the "Pragmas" section of the "Table of Contents" in the left-hand frame of the html docs.
If all you want to do is run the sub standalone to completion, then that is as simple as
use threads; sub YourSub { ... return $result; } ... my $thread = threads->new( \&YourSub, $arg1, $arg2, ... ); # If your not interested in the result from the sub then # $thread->detach; .... # Otherwise, this will retrieve the return value. # Note: This will block until the thread finishes. # One (of several) things missing from the API as it stands # is any way to determine if the thread has finished # without blocking. my $result = $thread->join;
If you need to communicate between your main code and the subs whilst it is running, then life gets a little more complicated.
If you give a clearer picture of what the sub is going to be doing (like the code:), then it may be possible to give a better example.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Create a separate process with a sub...
by liz (Monsignor) on Aug 15, 2003 at 11:23 UTC | |
by BrowserUk (Patriarch) on Aug 15, 2003 at 12:14 UTC | |
by liz (Monsignor) on Aug 15, 2003 at 12:43 UTC | |
by BrowserUk (Patriarch) on Aug 15, 2003 at 13:36 UTC | |
|
Re: Re: Create a separate process with a sub...
by Foggy Bottoms (Monk) on Aug 15, 2003 at 10:50 UTC | |
by bm (Hermit) on Aug 15, 2003 at 12:45 UTC | |
by Foggy Bottoms (Monk) on Aug 15, 2003 at 13:22 UTC |