use warnings; use strict; my $g = 100; my @c; my $n = 0; while(<>) { if (rand() < $g / ++$n) { splice @c, int(rand(@c)), $g <= @c, $_; } } print for @c;