locked_user rumos-er has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; my $array=[5,4,3,2,1]; srand(time()); my $cnt=0; while(scalar(@{$array}) ) { my $index=int(rand(scalar(@{$array}))); delete($array->[$index]); warn $index." ".scalar(@{$array}); $cnt++; sleep(1); }; warn $cnt;
| Replies are listed 'Best First'. | |
|---|---|
|
Re: using function delete with arrays
by cdarke (Prior) on Jul 17, 2007 at 11:24 UTC | |
by locked_user rumos-er (Novice) on Jul 17, 2007 at 13:52 UTC | |
by Anonymous Monk on Jul 17, 2007 at 17:14 UTC | |
by locked_user rumos-er (Novice) on Jul 18, 2007 at 06:24 UTC | |
by cdarke (Prior) on Jul 18, 2007 at 11:20 UTC | |
|
Re: using function delete with arrays
by moritz (Cardinal) on Jul 17, 2007 at 11:22 UTC | |
|
Re: using function delete with arrays
by locked_user rumos-er (Novice) on Jul 17, 2007 at 11:16 UTC | |
by moritz (Cardinal) on Jul 17, 2007 at 11:25 UTC | |
by moritz (Cardinal) on Jul 17, 2007 at 11:40 UTC | |
by dsheroh (Monsignor) on Jul 17, 2007 at 15:12 UTC |