in reply to How do I use a hash as a set?

The repeat operator (x) can be used with hash slices to get an easy to read set representation:

my @fruit_set = qw/apple banana orange mango/; my @vegie_set = qw/onion tomato lettuce eggplant/; my (%fruit, %vegetable); @fruit{@fruit_set} = (1) x @fruit_set; @vegetable{@vegie_set} = (1) x @vegie_set;