Daniel Falkenberg wrote:

<snip>
>%users = (
>          'username01' => {
>                      'Comp01' => '$0.00'
>                      },
>           'username02' => {
>                          'Comp02' => '$0.00'
>                        },
>           'usename03' => {
>                       'Comp03' => '-$9.90'
>  }
>);
>
>My questing is if I have the following variable...
>
>$variable = "usename01";
>
>How can I check that against the hash above.  If $variable doesn't match
>anything the print "Username does not match";

I'm not sure if you just want to check if the username exists, or get the
values associated with it. Also, it seems like you won't know the keys of
the nested hash. If that's the case the following checks to see if the key
$user exists and then gets the values in the associated hash.

if (defined(%{$users{$user}})){
    while((my $key, my $value)=each(%{$users{$user}})){
        print "$key: $value\n";
    }
}
else {
    print "No match for $user.";
}

Tagore Smith


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

Reply via email to