http://qs1969.pair.com?node_id=33835

Less than 80 characters each! Whoo-hoo!
# randomize, via Fisher-Yates @array[-$i,$j] = @array[$j,-$i] while $j = rand(@array - $i), ++$i < @ +array; # remove a chunk from the end and place at the beginning ("cutting") splice @array, 0, 0, splice(@array, rand @array); # weave an array, method 1 (ABCDEF => ADBECF) splice @array, @array/2 - $_, 0, pop @array for 0 .. (@array/2)-1; # weave an array, method 2 (ABCDEF => DAEBFC) splice @array, @array/2 + $_, 0, shift @array for 0 .. (@array/2)-1;

Replies are listed 'Best First'.
RE: Array One-liners
by merlyn (Sage) on Sep 24, 2000 at 18:44 UTC
    splice @array, 0, 0, splice(@array, rand @array);
    Good stuff, but typically we spell that:
    unshift @array, splice @array, rand @array;
    splice is cool, but you don't need to use it for the common thingies.

    -- Randal L. Schwartz, Perl hacker