Using Bit::Vector you can generate subsets of some set. Using -> increment to increment its value and ->contains to check a particular bit and ->Bit_On and ->Bit_Off to set bits. I think it suits your problem.
So in your case if you go over all bitstrings of 5 bits that have just 2 lit, you get what you have in your example.