in reply to forks, how do that?

While this dosn't actually answer your question about juggling forks, I will say that this is the perfect place to use threads. Whenever you want to return data from a process, a thread makes life easier. You didn't say or show how you were going to return values....I assume through external files? Anyways, here is a simple example using threads. It is simplified purposely for the example, in a real script, you probably would put everything into a hash.
#!/usr/bin/perl use warnings; use strict; use threads; my $thr1 = threads->new(\&sub1); my $thr2 = threads->new(\&sub2); my $thr3 = threads->new(\&sub3); my $ReturnData1 = $thr1->join; print "Thread1 returned @$ReturnData1\n"; my $ReturnData2 = $thr2->join; print "Thread2 returned @$ReturnData2\n"; my $ReturnData3 = $thr3->join; print "Thread3 returned @$ReturnData3\n"; print "Press any key to exit\n"; <>; ############################################## sub sub1 { my @values = ('Fifty-six','foo', 1); sleep 1; return \@values; } ############################################## sub sub2 { my @values = ('Forty-two','bar', 2); sleep 2; return \@values; } ########################################## sub sub3 { my @values = ('Sixty-six','baz', 3); sleep 3; return \@values; } # join() does three things: it waits for a thread to exit, # cleans up after it, and returns any data the thread may # have produced.

I'm not really a human, but I play one on earth. flash japh

Replies are listed 'Best First'.
Re^2: forks, how do that?
by apolo (Initiate) on Jan 01, 2006 at 22:37 UTC
    Ok, i try to get three page with lwp, in the "same" moment, i only think in fork function but you have reason, i don't know how to work theads but i'm test an tell you, anyway, if anyone know something about the forks problem, please tell me.

    Well, thank you.