BeneSphinx has asked for the wisdom of the Perl Monks concerning the following question:
I could writeif ($myfruit eq "bananas" || $myfruit eq "apples" || $myfruit eq "oran +ges"){ print "I like $myfruit!"; } else { print "I don't like $myfruit!"; }
Any ideas? I know that typically hash keys are used for set comparisons, but it's less elegant because I'd have to create the hash just for the comparison.if ($myfruit in ("bananas","apples","oranges")){ print "I like $myfruit!"; } else { print "I don't like $myfruit!"; }
|
|---|