You Can use defined() perl function ---------- From: John W. Krahn [SMTP:[EMAIL PROTECTED]] Sent: Tuesday, November 27, 2001 3:37 PM To: [EMAIL PROTECTED] Subject: Re: Checking to see if $user exists in a hash.
Daniel Falkenberg wrote: > > I have just created the hash that looks like this.... > > %users = ( > 'uucp' => '14', > 'daemon' => '2', > 'daniel' => '45', > 'test2' => '45', > 'halt' => '0', > 'test4' => '45' > ); > > $user = "test4"; > > Now here I want to see if $user exists in the hash... if it doesnt then > I want it to return an error. What would be the best way of going about > this? if ( exists $users{ $user } ) { # the %users hash has the key $user ... } perldoc -f exists John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ************************************************************************** This email (including any attachments) is intended for the sole use of the intended recipient/s and may contain material that is CONFIDENTIAL AND PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or distribution or forwarding of any or all of the contents in this message is STRICTLY PROHIBITED. If you are not the intended recipient, please contact the sender by email and delete all copies; your cooperation in this regard is appreciated. ************************************************************************** -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]