Hi Daniel,

On Wed, Nov 28, 2001 at 11:13:59AM +1030, Daniel Falkenberg 
([EMAIL PROTECTED]) said something similar to:
[snip]
> %users = (
>            'crud'  => '503',
>            'test'  => '45',
>            'test4' => '45',
>            'test2' => '45',
>            'daniel'=> '45'
>          );

[snip]
 
> #Check to see if #user exists
> if ( ! defined $users{$user} ) {
>   print "Sorry user $user does not exist! \n";
> }elsif (! defined $users{$user}{'45'} ) {
>   print "Sorry the user $user does not have a GID of 45! \n";
> } else {
>   print "Found $user! This user has a GID of 45! \n";
> }
> 
> For some reason it will check the first if statement (! defined
> $users{$user}) and check this OK.  But when I get to the second if
> statement ( ! defined $users{$user}{'45'} ) it will never return true no
> matter what $user is set to?  I figured that ! defined
> $users{$user}{'45'} would return false if for example $user = crud, but
> if $user = test4 then it should return to the last else statement?

There is no $user{test4}{45}. If the hash looked like the following, there
would be:

 %users = (
            'crud'  => '503',
            'test'  => '45',
            'test4' => {45 => 'fortyfive'},
            'test2' => '45',
            'daniel'=> '45'
          );

You really want that statement to look like:

 }elsif ($users{$user} != 45) {


Cheers,
Kevin

-- 
[Writing CGI Applications with Perl - http://perlcgi-book.com]
And now....you are going to dance...like you've never danced before!
        -- Frank Zappa

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

Reply via email to