in reply to Re: Matching a KEY in a HASH
in thread Matching a KEY in a HASH

I must not be making myself clear...

The $variable = "" could = Anim or CAD or anything in the list...

My question is ... How do I search the HASH to match the $variable, but print the VALUE only...

make sense?

Replies are listed 'Best First'.
Re: Re: Re: Matching a KEY in a HASH
by merlyn (Sage) on May 14, 2001 at 20:28 UTC
    I must not be making myself clear.

    The point of a hash is that a hash itself can find a value for a given key trivially.

    $value_you_are_looking_for = $category{$variable};
    There's no searching required. If there's an element with a key of $variable, then $value_you_are_looking_for has it. Otherwise, it gets undef.

    -- Randal L. Schwartz, Perl hacker