Silas has asked for the wisdom of the Perl Monks concerning the following question:
The basic process is "for each item in a list, script calls a subroutine with that item as input, and returns the corresponding output". I need to simultaneously execute the subroutine for each item in the list.
Using the "spawn" subroutine on page 351 of Programming Perl, I tried this:
my $output;
foreach my $item (@items) {
&spawn(sub { $output .= &search($item); });
}
This produces, at best, a looping that I couldn't begin to debug.I know this has been done before - multi-threaded searches, etc. seem commonplace. Anyone have any code snippets?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Fork/Spawn
by turnstep (Parson) on Mar 27, 2000 at 22:18 UTC | |
|
Re: Fork/Spawn
by Silas (Novice) on Mar 29, 2000 at 01:58 UTC | |
by chromatic (Archbishop) on Mar 29, 2000 at 03:53 UTC | |
by btrott (Parson) on Mar 29, 2000 at 02:12 UTC | |
|
Re: Fork/Spawn
by turnstep (Parson) on Mar 29, 2000 at 20:29 UTC |