in reply to Counting Random Elements
Don't worry about writing Perl. Solve your problem by hand, and write down the steps you took. Write it in English, or in pseudo-code.
Once you work the problem by hand, and explain it to someone else (even if that someone else is you), you'll be better able to start coding your solution.