in reply to (tye)Re2: Efficient random hash stuff
in thread Efficient random hash stuff

Ok, modified thus:
sub rand_element (\@); @array = ([1,3,5], [2,4,6]); # [keys], [values] ($k,$v) = rand_element(@array); sub rand_element (\@) { my $aref = shift; my $idx = rand @{$aref->[0]}; my ($k,$v) = ($aref->[0][$idx], $aref->[1][$idx]); my @last = (pop @{$aref->[0]}, pop @{$aref->[1]}); ($aref->[0][$idx],$aref->[1][$idx]) = @last if $idx < @{$aref->[0]}; return ($k,$v); }
While not tested, I do belive it works -- the code has been changed only to allow for the different structure.

Thanks again, tye/Tye.

$monks{japhy}++ while $posting;