in reply to Random Couple Script

If all you wanted was working code, the other replies should work nicely, but if you are interested to know what's wrong with your script, read on:

1) When I execute the code, I don't get any output. That's because your function randomize has an endless loop.

while (@file_contents) { $totalline++; }
This code increments $totalline until @file_contents is empty. Since there is no code that empties the array, this will never happen.

Probably you wanted to say 'foreach', so that the function tells you the size of @file_contents. But then the sub shouldn't be called 'randomize'. As a side note, you get the size of the array simply with 'scalar(@file_contents)'.

2) The splice in sub compile_list takes not only person $ng out, but $ng persons begining at position $ng. Use 'splice(@file_contents,$ng,1);'

By the way, in this sub a 'while (@file_contents)' as main loop would have been better, since you are finished when @file_contents is empty.

3) in sub makegroups you select two adjacent names out of the list, but you increment $fark only by 1. Try it out, you will see that every name except the first will be printed twice.

Ok, that's what I found out. If there is still something wrong with the script, put in 'print' statements to show you what is going on. The first thing I did with your script was to insert code like

print "Position 1: @file_contents\n";
between "interesting" lines in the sub compile_list to find out what it is doing. The endless loop was apparent immediately because the second print statement was never reached