in reply to generating combinations of elements of an arbitrary number of arrays
Set::CrossProduct does exactly what you want.