use strict; use warnings; my ($n, $t); my @arr = (0,1,2,3,4,5,6,7,8,9); for (0..($#arr-1)) { $n = int (rand() * ($#arr - $_ + 1)) + $_; $t = $arr[$n]; $arr[$n] = $arr[$_]; $arr[$_] = $t; } #### For all items except last Pick random item between current item and last Swap that item with current item