in reply to Random Couple Script
The typical approach would be to read the data into an array, shuffle it, then just pull off the elements (in this case pairs)
# simulate chomp( my @people = <FILE> ); my @people = qw( bobby jane charlen markus gabriel alex ); fisher_yates_shuffle(\@people); printf "Pair %s %s\n", shift(@people),shift(@people) while @people; sub fisher_yates_shuffle { my $array = shift; for (my $i = @$array; --$i; ) { my $j = int rand ($i+1); next if $i == $j; @$array[$i,$j] = @$array[$j,$i]; } }
cheers
tachyon
|
|---|