while ( @list ) { # list not empty $randint = int(rand(@list)); # pick a random index # remove the selected (one) item from @list, and append it to @list2 push @list2, splice(@list, $randint, 1); }