Help for this page

Select Code to Download


  1. or download this
    perl -we 'my $k = int(shift); my @a; my $l = 0; while (<>) { if ($l++ 
    +< $k) { push @a, $_ } else { if ((my $j = rand($l)) < $k) { $a[$j] = 
    +$_; } } } print @a;' 3 filename
    
  2. or download this
    $ cat a
    one
    ...
       1578 one six two 
       1578 four one three 
    $