in reply to Array to Hash
Use a hash slice:
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};
|
---|
Replies are listed 'Best First'. | |
---|---|
RE: Re: Array to Hash
by takshaka (Friar) on May 10, 2000 at 20:35 UTC | |
RE: Re: Array to Hash
by httptech (Chaplain) on May 10, 2000 at 20:36 UTC | |
by plaid (Chaplain) on May 10, 2000 at 21:25 UTC | |
by Danimal (Novice) on May 12, 2000 at 20:13 UTC | |
by Danimal (Novice) on May 12, 2000 at 20:22 UTC |
In Section
Seekers of Perl Wisdom