How can I convert an array of n elements to a hash with those n elements as keys?Like so
my @array = qw( foo bar baz quux ); my %hash = map { $_ => 1 } @array;
Will it work or removing elements while running on the hash can cause problems of some sort?You need to change
todelete($key);
And assuming isPassTest() is performing the tests correctly it should work fine, although you will need to exit the loop at some point e.g last if 0 == keys %myhash;delete($myhash{$key});
_________
broquaint
In reply to Re: converting ana array to a hash
by broquaint
in thread converting ana array to a hash
by hotshot
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |