title: How can I generate all ordered combinations of length k in Perl?
body: <p>I need a subroutine that, given a set of characters, will generate all possible combinations of those characters of length k. Order matters and reuse is allowed, so if <code>k = 2</code> then <code>AB != BA</code> and <code>AA</code> is an option. I found <a href="http://www.perlmonks.org/?node_id=75261" rel="nofollow">some working examples on PerlMonks</a>, but unfortunately they are code golf and not easy for me to wrap my mind around. Can someone please do one or more of the following?</p>
  
  <ol>
  <li>Give a breakdown and explanation of how the first algorithm works.</li>
  <li>De-obfuscate the code so that the meaning is clearer.</li>
  <li>Point me toward another example that is clearer.</li>
  </ol>
  
  <p>Thanks!</p>