Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Perl >> Snippet

shuffle an array randomly


while ( @old )
   { push ( @new , splice ( @old , rand @old , 1)); }     # randomly pick element for swapping