Thread Zufällige Ausgabe (12 answers)
Opened by havi at 2005-09-12 12:05

esskar
 2005-09-12 12:14
#57828 #57828
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
my $max = 700;
my %seen = ();
my $run = 1;
while($run) {
my $lncount = 0;
  while(<IN>) {  
     my $r = int(rand(2));
     if($r == 0 and not exists $seen{$lncount}) {
        print OUT $_;
        $seen{$lncount} = 1;
        --$max;
        if($max == 0) {
            $run = 0;
            last;
        }        
     }
     ++$lncount;
  }
  seek(IN, 0, 0) if $run;
}


ungetestet\n\n

<!--EDIT|esskar|1126513011-->

View full thread Zufällige Ausgabe