# Read names, extracting what's after the dot and before the end of line my @names = map /\.(.*)/, ; # Shuffle the list use List::Util 'shuffle'; @names = shuffle(@names); # Print them out two by two for (1..@names/2) { print "Group $_: $names[$_*2-2] and $names[$_*2-1] are partners\n"; } __DATA__ 1.bobby 2.jane 3.charleen 4.markus 5.gabriel 6.Alex