in reply to Re: Random Couple Script
in thread Random Couple Script
Update: using Thospel's idea, one of the splices could be replaced with a simple shift:# Read names, chop off numbers my @names = map /\.(.*)/, <DATA>; # Pair them up randomly for (1..@names/2) { printf "Group $_: %s and %s are partners\n", splice(@names, rand(@na +mes), 1) , splice(@names, rand(@names), 1); }
printf "Group $_: %s and %s are partners\n", shift(@names), splice(@ +names, rand(@names), 1);
|
|---|