use List::Util qw[ shuffle ]; ## near the top of your program. ... @{ $haplotypes{$currentPop } } = shuffle @{ $haplotypes{$currentPop } };