my @lines = ; for my $c (1 .. 300) { my $line; for my $i (0 .. $#lines) { rnd($i+1)<1 and $line = $#lines[$i]; } print OUT $line; }