(keys %hash) is a list of the keys for %hash. The scalar assignment $input = (keys %hash) puts the number of keys into $input (which is probably not what you want to do). OTOH, to compare $input to each of the keys, you need to loop through the keys, comparing $input to each key. Since the keys (and the user input) are strings, you use eq to do the comparison.
Updated: Scrub the stupidity; no need to check everything; this is a hash, after all.
In reply to Re: the if statement
by broomduster
in thread the if statement
by kwn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |