in reply to Combinations of a set of elements

This is in the perlfaq documents. Try

perldoc -q permute
and you can see sample code.