in reply to Re: random picks from hash
in thread random picks from hash

well i'm tryin to get 15 examples for each $arzt_nr....
currently i have this :

open(OUTPUT, $file3) || die "Datei nicht gefunden"; #outputfile öf +fnen foreach my $arzt_nr (keys %Ordnung){ my @versnummer = (keys %{ $Ordnung{$arzt_nr}{$vknr}}); for (1..15){ my $verrand = $versnummer[rand @versnummer] ; print OUTPUT "$arzt_nr;"; print OUTPUT "$Ordnung{$arzt_nr}{$vknr}{$verrand}{bht};"; print OUTPUT "$Ordnung{$arzt_nr}{$vknr}{$verrand}{gnr};"; print OUTPUT "$Ordnung{$arzt_nr}{$vknr}{$verrand}{Name};"; print OUTPUT "$Ordnung{$arzt_nr}{$vknr}{$verrand}{Vorname} +;"; print OUTPUT "$Ordnung{$arzt_nr}{$vknr}{$verrand}{Geburtst +ag};"; print OUTPUT "$vknr;"; print OUTPUT "$_\n"; } } close (OUTPUT); }
it's almost fine when there are more then 15 possibilities (get the same output twice sometimes), but i still got problems if there are less....tryin to figure that out atm 8)

thx for the help, especially the 2nd ano monk's post was very helpful