use List::Util 'shuffle'; my @A = qw- 1 2 3 4 -; @A = shuffle @A; say "@A";