The answer has nothing to do with perl, only with math.
First you have to tell us if the containers have a maximal capacity; from your examples I'd guess so. If that's the case, the number of combinations is the factorial of the total capacity of all containers, divided by the product of the factorials of each capacity. So in your example
2! * 2! * 2!
This assumes that order insider containers doesn't matter, ie that 12 34 5 is the same as 21 34 5, but that the order of containers does matter. (If it doesn't, you need to divide by the factorial of number containers).
If that's not what you want, you have to provide a few more details.
- links to (nearly) everything that is Perl 6.