in reply to RE: Merging two @ARRAYS into a %HASH
in thread Merging two @ARRAYS into a %HASH

Everything chromatic says, but also, I thought I'd add that hash slices are very useful for stuffing an array into a hash (as in the original example). For example, say that you had a list of elements and you wanted to check if certain items were in that list. The best way to do this is with a hash, generally, and it's very easy to set up such a hash for lookups:
my @list = qw/foo bar baz/; my %hash; @hash{@list} = (); # now I can test if an element is in @list # by checking if the key exists in %hash if (exists $hash{"foo"}) { print "found foo!"; }