On Sat, 4 Jun 2005 12:05:06 -0700, you wrote: >Hopefully quick syntax/philosophy question: > >I have a array grep like this: > my @newArray = grep ($something, $maybeBiggerOriginalArray); > >but would much prefer to take greps list and use it as the keys of a hash. Now >the keylist of a hash cannot be modified, i.e. > (keys $newHash) = grep (...) >is rightly forbidden nonsense. > >obviously you can do this in a 2-step by e.g. do the first grep, and then > foreach (@newArray) { $newHash{$_} -> {thing} = $_; } # or assign >whatever > >but thats hideous. any tips on how to dump a list to the keys of a hash >directly? once again i'm sure i'm missing something.
Without knowing precisely what values you wish to assign to the hash elements, I believe you should be able to use a hash slice: @newHash{grep $something, $MaybeBiggerOriginalArray} = @ValuesArray; -- Eric Amick Columbia, MD _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs