DaniWeb IT Discussion Community

Code Snippets (http://www.daniweb.com/code/)
-   perl (http://www.daniweb.com/code/perl.html)
-   -   Shuffling an array randomly (http://www.daniweb.com/code/snippet542.html)

KevinADC perl syntax
Aug 28th, 2006
Use the List::Util module. I believe List::Util is a core module starting with perl 5.8. For older versions of perl you may need to install the module. See the module documentation for more details: List::Util

  1. use List::Util 'shuffle';
  2. my @deck = (1..52);
  3. my @shuffled_deck = shuffle(@deck);