my @d; my @p; for (my $i=0;$i<500000000;$i++) { my ($p1,$p2) = getPair(); $d[$p1] += 1; $d[$p2] += 1; push @p, [ $p1, $p2]; }