At 07:05 PM 6/4/05 -0700, $Bill Luebkert wrote: >One more using the hash slice suggestion: > >my %hash2; >@hash2{grep /$something/, @array} = (1) x @array;
I wasn't aware that u could take a slice of a hash. Interesting. I had to try it out to see if it actually worked and I came up with another little benefit of doing it. You can keep track of the insert order into the hash and the match from the grep array. perl $a = "bob"; @b = qw(bob joe bobby bobbie lem shemp); @c = qw(1 2 3 4 5 6 7 8 9); @hash{grep /$a/, @b} = @c; print "keys in hash ", join("|", keys %hash); print "\n"; foreach $i (keys %hash) { print "$i $hash{$i}\n" } keys in hash bobby|bob|bobbie bobby 2 bob 1 bobbie 3 Also changing the @hash to a $hash to force a scalar context gives an interesting result as well. Though dubiously useful. -- REMEMBER THE WORLD TRADE CENTER ---=< WTC 911 >=-- "...ne cede males" 00000100 _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs