[Israel.pm] array 2 hash for quick search

Shlomo Yona shlomo at cs.haifa.ac.il
Tue Jun 15 01:51:19 PDT 2004


Hello,

Is there any other idiom for transforming an array to a hash
for quick search? I'm looking for some short hack.

sub array2hash {
	my ($array) = @_;
	my %hash;
	foreach my $array_item (@$array) {
		$hash{$array_item}++
	}
	return \%hash;
}

Thanks.

-- 
Shlomo Yona
shlomo at cs.haifa.ac.il
http://cs.haifa.ac.il/~shlomo/



More information about the Perl mailing list