use strict; use List::Util qw(shuffle); my @train = (1, 2, 3, 4, 1, 2, 4, 4, 1, 2, 3, 4, 1); my @test = shuffle @train; # my @test = @train;