in reply to random pairs
Try searching CPAN for combinatorics-related modules, for example, Math::Combinatorics or Algorithm::Combinatorics. Also, it may be easier to help you if you tell us the purbose of generating such pairs of numbers (maybe it can be optimised too).
EDIT: example code
#!/usr/bin/perl use warnings; use strict; use Math::Combinatorics; my @n = (0..99); my $cmb = Math::Combinatorics->new(count => 2, data => [@n]); my %numbers; $numbers{$_} = [] for @n; while (my ($x,$y) = $cmb->next_combination) { # never returns $x == 99 +, so $numbers{99} will be always empty :( push $numbers{$x},$y; } print "($_,",$numbers{$_}->[int(rand($#{$numbers{$_}}+1))],")\n" for @ +n;
|
|---|