Incidentally nice work on the select and shuffle problems. Marginally less efficient than my solution, but a lot shorter. (Well technically your solution is quadratic, but the quadratic bit has a small constant.)
Was efficiency a requirement? If it was, then oops. Oh, well, I was optimizing for brevity.
P.S. I wasn't able to inline the "@x" when I tried it (must be because I'm using a much older perl). I didn't throw in the $z="@x"; just to waste space. I was actually pretty disapointed at having to do so. Nice. I should really upgrade my perl (or at least have a more up-to-date version around).