If you don't care about the keys having values, but just want them to exist, you can just do:my @array = qw/foo bar baz quux/; my %hash; @hash{@array} = (1) x @array;
But now you need to test for existence in the hash by using exists:@hash{@array} = ();
print "foo is there" if exists $hash{foo};
In reply to Re: Array to Hash
by btrott
in thread Array to Hash
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |