in reply to rand + shift || pop
Yet Another Way (for the senile who don't remember shift):
#!/usr/bin/perl use strict; use warnings; # 878281 my @array = ("a", "b", "c", "d", "e", "f",); my $i = int(rand(6)); my $array = $array[$i]; undef $array[$i]; print "\t\$i: $i and \$array: $array \n"; print "\tRemaining \@array: \t"; no warnings qq(uninitialized); for $array(@array) { if (defined($array)) { print $array . "\t"; } else { next; } } print "\n done!\n";
Looping around this, if one wishes to exhaust the array, is left as an exercise for the interested.
|
|---|