Others have addressed various other parts of your code, such as why you're
forking twice, what the while loop is for, etc.  However, there are a few
things in your code that others haven't addressed.


On Thu, Sep 26, 2002 at 09:20:37AM -0400, chad kellerman wrote:
[snip]
> foreach my $usr (@users) {
>       my $UsrPid;
>       unless ($UsrPid = fork) {
>             while fork {
>                   do stuff
>                   exit 0;
>             }
>             exit 0;
>        }
>        waitpid($UsrPid,0);
> } 
> if (defined @otherusers)

Checking for defined'ness on an array is almost certainly wrong.  You
probably simply want to check if there are any elements, which simply
requires:

    if (@otherusers)

You're also missing an open brace after the if.


>       foreach my $usr2 (@otherusers) {

The test of @otherusers is redundant because of this loop.  If @otherusers
has no elements this loop will never be run.


>             my $oUsrPid;
>             unless ($oUsrPid = fork) {
>                    while fork {
>                           do stuff
>                           exit 0;
>                    }
>                    exit 0;
>              }
>              exit 0;
>        }
>        waitpid($oUsrPid,0);

$oUsrPid is not in scope here; you've declared it inside the foreach loop,
but you're using it outside of that block.  You probably meant to use it
inside the block.  This will cause a fatal error with use strict; you are
using strict, right?


> }


Michael
--
Administrator                      www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to