my @keys = keys %{{f}}; #### use List::Util qw( shuffle uniq pairkeys ); my @keys = shuffle uniq pairkeys f;