in reply to Random Picks

This code does the same thing as knobunc's, but it also keeps the randomly selected lines in their original order:
my $select = 1000; my @ssns; while (my($ssn) = $sth->fetchrow_array()) { push @ssns, $_ if rand() < ($select / ++$count); if (@ssns > $select) { splice(@ssns, rand($#ssns), 1); } }
This is less efficient, though, because it has to move the elements of the @ssns array down every time it splices one out. knobunc's is O(n), while this is O(n*m), where n is the total number of items and m is the number of items to select. (I hope I got that right! :)