Hi Rob, Rob Dixon wrote:
>Hi Jan. > >If you want to test a static (unchanging) array for the containment of many >different >values you should build a hash out of the array elements: > > my @data = 'a' .. 'm'; > my %data_hash; > @[EMAIL PROTECTED] = (); > I see. But shouldn't the last line be a complete hash slice: [EMAIL PROTECTED] = (); >Then simply check for the existence of a hash element with the >required value as a key: > > > for (split '', 'robdixon') { > if (exists $data_hash{$_}) { > printf "Element %s found in [EMAIL PROTECTED]", $_; > } > else { > printf "Element %s isn't in [EMAIL PROTECTED]", $_; > } > } > I thought of the exists function, but I always hesitate to use a hash if my data is not really hash-like. Thinking perlish is still on my to do list. Thank you! - Jan -- How many Microsoft engineers does it take to screw in a lightbulb? None. They just redefine "dark" as the new standard. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>