Steve Greenland <[EMAIL PROTECTED]> writes: > Uh, wait, no, now that I think about, it, the new way is not that much > clearer and easier. Hmmm. Perhaps I'm not understanding the benefits of > libfork-perl. Maybe if there was a place in the package description to > summarize what features libfork-perl provides, and how it makes fork > development[1] easier.
Well it was origninaly designed to run function many times in parallel in background an get its return value. imagine this small script: sub b($) { return "<$_[0]>"; } sub test_fork($) { my $args = shift; sleep $args->[2]; return [$args->[0], b $args->[1]]; } my $data = [ # ID, data, sleep... [1 ,"Item 1", 1], [2 ,"Item 6", 6], [3 ,"Item 2", 2], [4 ,"Item 5", 3], [5 ,"Item 3", 5], [6 ,"Item 4", 4], ]; my $values = fork_it { fct => \&test_fork, args => $data, max_children => 6, timeout => 10, }; my $sorted_values = [ sort { $a->[0] cmp $b->[0] } (@$values) ]; print Dumper $sorted_values; will return $VAR1 = [ [ 1, '<Item 1>' ], [ 2, '<Item 6>' ], [ 3, '<Item 2>' ], [ 4, '<Item 5>' ], [ 5, '<Item 3>' ], [ 6, '<Item 4>' ] ]; -- Sebastien J. Gross | Debian GNU/Linux [EMAIL PROTECTED] | http://www.debian.org GPG: 1024g/AF0DDC9A AB35 1FFB 1268 56C0 452B 302E 2A25 8421 53BB A490