Help for this page

Select Code to Download


  1. or download this
    use warnings; use strict; my $g = 100; my @c; my $n = 0; while(<>) { i
    +f (rand() < $g / ++$n) { splice @c, int(rand(@c)), $g <= @c, $_; } } 
    +print for @c;
    
  2. or download this
    use warnings; use strict; my $g = 100; my %c; my %n; while(<>) { my $l
    + = /(.)/ && lc($1); my $c = \@{$c{$l}}; if (rand() < $g / ++$n{$l}) {
    + splice @$c, int(rand(@$c)), $g <= @$c, $_; } } print @$_ for values(
    +%c);