in reply to while/fork problem
#here while (<IN>) { #for (<IN>) { chomp; $rcount++; $tcount++; print "Progress: $tcount\n"; # changed \r to \n $pid = fork; if ($pid==0) { # child close IN; print "child pid $$\n"; # new debug line # start call sleep sub
your script produces
Progress: 1 child pid 21079 Progress: 2 child pid 21080 Progress: 3 child pid 21081 Progress: 4 child pid 21082 ...
so I guess it works as expected. It is definitely a better to use while() if you don't need the entire bunch of lines (e.g. to sort them first), but one line at a time.
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: while/fork problem
by hammopau (Novice) on Jun 13, 2007 at 07:40 UTC |